2011-09-24 23:09:48 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-11-05 17:04:10 +00:00
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2011-09-24 23:09:48 +00:00
|
|
|
pandora.ui.usersDialog = function() {
|
2011-10-03 09:31:20 +00:00
|
|
|
|
2012-03-21 13:07:19 +00:00
|
|
|
var browsers = [
|
2013-07-30 17:03:27 +00:00
|
|
|
'Camino', 'Chrome Frame', 'Chrome', 'Chromium', 'Epiphany',
|
2012-10-27 19:35:20 +00:00
|
|
|
'Firefox', 'Internet Explorer', 'Konqueror', 'Nokia Browser',
|
|
|
|
'Opera', 'Safari', 'WebKit'
|
2012-03-21 13:07:19 +00:00
|
|
|
],
|
|
|
|
dialogHeight = Math.round((window.innerHeight - 48) * 0.9),
|
2011-12-18 09:27:15 +00:00
|
|
|
dialogWidth = Math.round(window.innerWidth * 0.9),
|
|
|
|
formWidth = 256,
|
2011-10-03 09:31:20 +00:00
|
|
|
numberOfUsers = 0,
|
2012-03-21 13:07:19 +00:00
|
|
|
systems = [
|
2012-10-27 16:57:28 +00:00
|
|
|
'Android', 'BlackBerry', 'BSD', 'iOS', 'Java', 'Linux', 'Mac OS X',
|
2013-07-30 17:03:27 +00:00
|
|
|
'Nokia', 'PlayStation', 'RIM Tablet OS', 'Unix', 'Wii',
|
|
|
|
'Windows Phone', 'Windows'
|
2012-03-21 13:07:19 +00:00
|
|
|
],
|
2012-05-24 08:22:56 +00:00
|
|
|
userLevels = pandora.site.userLevels.map(function(userLevel) {
|
|
|
|
return Ox.toTitleCase(userLevel);
|
|
|
|
}).concat(['Robot']),
|
2011-10-03 09:31:20 +00:00
|
|
|
|
2012-03-20 07:19:03 +00:00
|
|
|
$reloadButton = Ox.Button({
|
2013-01-01 13:10:41 +00:00
|
|
|
disabled: true,
|
2012-03-20 07:19:03 +00:00
|
|
|
title: 'redo',
|
2013-05-09 10:13:58 +00:00
|
|
|
tooltip: Ox._('Reload'),
|
2012-03-20 07:19:03 +00:00
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'left', margin: '4px 2px 4px 4px'})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
2013-01-01 13:10:41 +00:00
|
|
|
$reloadButton.options({disabled: true});
|
2012-03-21 06:57:40 +00:00
|
|
|
Ox.Request.clearCache('findUsers');
|
2012-03-20 07:19:03 +00:00
|
|
|
$list.reloadList(true);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
2011-11-12 10:39:50 +00:00
|
|
|
$guestsCheckbox = Ox.Checkbox({
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Include Guests'),
|
2012-02-05 11:19:40 +00:00
|
|
|
value: false
|
2011-11-12 10:39:50 +00:00
|
|
|
})
|
2013-04-26 09:11:17 +00:00
|
|
|
.css({float: 'left', margin: '4px 2px'})
|
2012-04-19 09:52:36 +00:00
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
data.value
|
|
|
|
? $robotsCheckbox.show()
|
|
|
|
: $robotsCheckbox.hide().options({value: false});
|
|
|
|
updateList();
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
$robotsCheckbox = Ox.Checkbox({
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Include Robots'),
|
2012-04-19 09:52:36 +00:00
|
|
|
value: false
|
|
|
|
})
|
2013-04-26 09:11:17 +00:00
|
|
|
.css({float: 'left', margin: '4px 2px'})
|
2012-04-19 09:52:36 +00:00
|
|
|
.hide()
|
2011-11-12 11:02:54 +00:00
|
|
|
.bindEvent({
|
|
|
|
change: updateList
|
|
|
|
}),
|
2011-11-12 10:39:50 +00:00
|
|
|
|
2011-10-03 09:31:20 +00:00
|
|
|
$findSelect = Ox.Select({
|
|
|
|
items: [
|
2013-05-09 10:13:58 +00:00
|
|
|
{id: 'all', title: Ox._('Find: All')},
|
|
|
|
{id: 'username', title: Ox._('Find: Username')},
|
2014-09-30 12:26:14 +00:00
|
|
|
{id: 'email', title: Ox._('Find: E-Mail Address')},
|
|
|
|
{id: 'group', title: Ox._('Find: Group')}
|
2011-10-03 09:31:20 +00:00
|
|
|
],
|
|
|
|
overlap: 'right',
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
2011-11-12 11:02:54 +00:00
|
|
|
$findInput.value() && updateList();
|
2013-03-24 09:39:43 +00:00
|
|
|
$findInput.options({placeholder: data.title});
|
2011-10-03 09:31:20 +00:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
$findInput = Ox.Input({
|
|
|
|
changeOnKeypress: true,
|
|
|
|
clear: true,
|
2013-07-17 10:25:01 +00:00
|
|
|
placeholder: Ox._('Find: All'),
|
2011-10-03 09:31:20 +00:00
|
|
|
width: 192
|
|
|
|
})
|
|
|
|
.bindEvent({
|
2011-11-12 11:02:54 +00:00
|
|
|
change: updateList
|
2011-10-03 09:31:20 +00:00
|
|
|
}),
|
|
|
|
|
|
|
|
$findElement = Ox.FormElementGroup({
|
|
|
|
elements: [
|
|
|
|
$findSelect,
|
|
|
|
$findInput
|
|
|
|
]
|
|
|
|
})
|
|
|
|
.css({float: 'right', margin: '4px'}),
|
|
|
|
|
2012-06-27 07:41:39 +00:00
|
|
|
$list = Ox.TableList({
|
2011-10-03 09:31:20 +00:00
|
|
|
columns: [
|
|
|
|
{
|
2012-04-16 17:30:25 +00:00
|
|
|
format: function(value, data) {
|
2011-10-03 09:31:20 +00:00
|
|
|
return $('<img>')
|
|
|
|
.attr({
|
2014-09-26 12:30:51 +00:00
|
|
|
src: Ox.UI.getImageURL('symbolCheck')
|
2011-10-03 09:31:20 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '10px',
|
|
|
|
height: '10px',
|
|
|
|
padding: '3px',
|
2012-04-16 17:30:25 +00:00
|
|
|
opacity: value || [
|
|
|
|
'guest', 'robot'
|
2012-04-19 09:18:16 +00:00
|
|
|
].indexOf(data.level) > -1 ? 0 : 1
|
2011-10-03 09:31:20 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
id: 'disabled',
|
|
|
|
operator: '-',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Enabled'),
|
2011-12-18 09:27:15 +00:00
|
|
|
titleImage: 'check',
|
2011-10-03 09:31:20 +00:00
|
|
|
visible: true,
|
|
|
|
width: 16
|
|
|
|
},
|
2012-04-19 14:26:52 +00:00
|
|
|
{
|
|
|
|
format: function(value) {
|
|
|
|
return $('<img>')
|
|
|
|
.attr({
|
2014-09-26 12:30:51 +00:00
|
|
|
src: Ox.UI.getImageURL('symbolMail')
|
2012-04-19 14:26:52 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '10px',
|
|
|
|
height: '10px',
|
|
|
|
padding: '3px',
|
|
|
|
opacity: +value
|
|
|
|
});
|
|
|
|
},
|
|
|
|
id: 'newsletter',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Newsletter'),
|
2012-04-19 14:26:52 +00:00
|
|
|
titleImage: 'mail',
|
|
|
|
operator: '-',
|
|
|
|
visible: true,
|
|
|
|
width: 16
|
|
|
|
},
|
2012-03-21 13:20:22 +00:00
|
|
|
{
|
|
|
|
format: function(value, data) {
|
|
|
|
return '<span style="opacity: ' + (
|
|
|
|
data.disabled ? 0.5 : 1
|
|
|
|
) + '">' + Ox.encodeHTMLEntities(value) + '</span>';
|
|
|
|
},
|
|
|
|
id: 'username',
|
|
|
|
operator: '+',
|
|
|
|
removable: false,
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Username'),
|
2012-03-21 13:20:22 +00:00
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 128
|
2012-03-21 13:20:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
format: function(value, data) {
|
|
|
|
return '<span style="opacity: ' + (
|
|
|
|
data.disabled ? 0.5 : 1
|
|
|
|
) + '">' + value + '</span>';
|
|
|
|
},
|
|
|
|
id: 'email',
|
|
|
|
operator: '+',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('E-Mail Address'),
|
2012-03-21 13:20:22 +00:00
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 192
|
2012-03-21 13:20:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'center',
|
2012-04-19 14:30:09 +00:00
|
|
|
format: function(value) {
|
2012-03-21 13:20:22 +00:00
|
|
|
return Ox.Theme.formatColorLevel(
|
2012-03-26 19:27:20 +00:00
|
|
|
userLevels.indexOf(Ox.toTitleCase(value)),
|
2012-03-21 13:20:22 +00:00
|
|
|
userLevels,
|
|
|
|
[0, 300]
|
|
|
|
);
|
|
|
|
},
|
|
|
|
id: 'level',
|
|
|
|
operator: '-',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Level'),
|
2012-03-21 13:20:22 +00:00
|
|
|
type: 'label',
|
|
|
|
visible: true,
|
2014-03-04 19:37:15 +00:00
|
|
|
width: 80
|
2012-03-21 13:20:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
format: function(value) {
|
2013-08-05 13:56:40 +00:00
|
|
|
return value ? Ox.Element({
|
2012-03-21 13:07:19 +00:00
|
|
|
element: '<img>',
|
|
|
|
tooltip: value
|
|
|
|
})
|
|
|
|
.attr({
|
2012-03-27 07:14:59 +00:00
|
|
|
src: Ox.getFlagByGeoname(value, 16)
|
2012-03-21 13:07:19 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '14px',
|
|
|
|
height: '14px',
|
|
|
|
borderRadius: '4px',
|
|
|
|
marginLeft: '-3px',
|
|
|
|
marginTop: 0
|
2013-08-05 13:56:40 +00:00
|
|
|
}) : '';
|
2012-03-21 13:07:19 +00:00
|
|
|
},
|
|
|
|
id: 'location',
|
|
|
|
operator: '+',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Location'),
|
2012-03-21 13:07:19 +00:00
|
|
|
titleImage: 'flag',
|
|
|
|
visible: true,
|
|
|
|
width: 16
|
|
|
|
},
|
|
|
|
{
|
|
|
|
format: function(value) {
|
2012-03-21 14:01:18 +00:00
|
|
|
var system;
|
|
|
|
Ox.forEach(systems, function(s) {
|
|
|
|
if (new RegExp('^' + s).test(value)) {
|
|
|
|
system = s;
|
2012-07-04 11:40:37 +00:00
|
|
|
return false;
|
2012-03-21 13:07:19 +00:00
|
|
|
}
|
|
|
|
});
|
2012-03-21 14:01:18 +00:00
|
|
|
return system ? Ox.Element({
|
2012-03-21 13:07:19 +00:00
|
|
|
element: '<img>',
|
|
|
|
tooltip: value
|
2012-03-27 10:29:32 +00:00
|
|
|
.replace(/BSD \((.+)\)/, '$1')
|
|
|
|
.replace(/Linux \((.+)\)/, '$1')
|
|
|
|
.replace(/Unix \((.+)\)/, '$1')
|
|
|
|
.replace(/Windows (NT \d+\.\d+) \((.+)\)/, 'Windows $2 ($1)')
|
2012-03-21 13:07:19 +00:00
|
|
|
})
|
|
|
|
.attr({
|
2014-09-26 12:41:53 +00:00
|
|
|
src: Ox.UI.PATH + 'png/system'
|
2012-03-21 14:01:18 +00:00
|
|
|
+ system.replace(/ /g, '') + '128.png'
|
2012-03-21 13:07:19 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '14px',
|
|
|
|
height: '14px',
|
|
|
|
marginLeft: '-3px',
|
|
|
|
marginTop: 0
|
|
|
|
}) : '';
|
|
|
|
},
|
2012-03-21 14:01:18 +00:00
|
|
|
id: 'system',
|
2012-03-21 13:07:19 +00:00
|
|
|
operator: '+',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('System'),
|
2012-04-16 09:22:56 +00:00
|
|
|
titleImage: 'square',
|
2012-03-21 13:07:19 +00:00
|
|
|
visible: true,
|
2012-03-21 14:01:18 +00:00
|
|
|
width: 16
|
2012-03-21 13:07:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
format: function(value) {
|
2012-03-21 14:01:18 +00:00
|
|
|
var browser;
|
|
|
|
Ox.forEach(browsers, function(b) {
|
|
|
|
if (new RegExp('^' + b).test(value)) {
|
|
|
|
browser = b;
|
2012-07-04 11:40:37 +00:00
|
|
|
return false;
|
2012-03-21 13:07:19 +00:00
|
|
|
}
|
|
|
|
});
|
2012-03-21 14:01:18 +00:00
|
|
|
return browser ? Ox.Element({
|
2012-03-21 13:07:19 +00:00
|
|
|
element: '<img>',
|
|
|
|
tooltip: value
|
|
|
|
})
|
|
|
|
.attr({
|
2014-09-26 12:41:53 +00:00
|
|
|
src: Ox.UI.PATH + 'png/browser'
|
2012-03-21 14:01:18 +00:00
|
|
|
+ browser.replace(/ /g, '') + '128.png'
|
2012-03-21 13:07:19 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '14px',
|
|
|
|
height: '14px',
|
|
|
|
marginLeft: '-3px',
|
|
|
|
marginTop: 0
|
|
|
|
}) : '';
|
|
|
|
},
|
2012-03-21 14:01:18 +00:00
|
|
|
id: 'browser',
|
2012-03-21 13:07:19 +00:00
|
|
|
operator: '+',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Browser'),
|
2012-04-16 09:22:56 +00:00
|
|
|
titleImage: 'circle',
|
2012-03-21 13:07:19 +00:00
|
|
|
visible: true,
|
2012-03-21 14:01:18 +00:00
|
|
|
width: 16
|
2012-03-21 13:07:19 +00:00
|
|
|
},
|
2011-12-18 09:27:15 +00:00
|
|
|
{
|
2012-03-21 13:20:22 +00:00
|
|
|
align: 'right',
|
2011-12-18 09:27:15 +00:00
|
|
|
format: function(value) {
|
2012-03-21 13:20:22 +00:00
|
|
|
return Ox.formatNumber(value);
|
2011-12-18 09:27:15 +00:00
|
|
|
},
|
2011-10-03 09:31:20 +00:00
|
|
|
id: 'timesseen',
|
|
|
|
operator: '-',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Times Seen'),
|
2011-10-03 09:31:20 +00:00
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 80
|
2011-10-03 09:31:20 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
2011-10-03 11:37:46 +00:00
|
|
|
format: function(value) {
|
2012-10-31 23:54:09 +00:00
|
|
|
return Ox.formatDate(value, '%F %T');
|
2011-10-03 11:37:46 +00:00
|
|
|
},
|
2011-10-03 09:31:20 +00:00
|
|
|
id: 'firstseen',
|
|
|
|
operator: '-',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('First Seen'),
|
2011-10-03 09:31:20 +00:00
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 144
|
2011-10-03 09:31:20 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
2011-10-03 11:37:46 +00:00
|
|
|
format: function(value) {
|
2012-10-31 23:54:09 +00:00
|
|
|
return Ox.formatDate(value, '%F %T');
|
2011-10-03 11:37:46 +00:00
|
|
|
},
|
2011-10-03 09:31:20 +00:00
|
|
|
id: 'lastseen',
|
|
|
|
operator: '-',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Last Seen'),
|
2011-10-03 09:31:20 +00:00
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 144
|
2011-10-03 09:31:20 +00:00
|
|
|
},
|
2012-03-21 13:20:22 +00:00
|
|
|
{
|
|
|
|
align: 'right',
|
2012-04-19 14:30:09 +00:00
|
|
|
format: function(value, data) {
|
|
|
|
return ['guest', 'robot'].indexOf(data.level) > -1
|
|
|
|
? '' : value;
|
|
|
|
},
|
|
|
|
id: 'numberoflists',
|
2012-03-21 13:20:22 +00:00
|
|
|
operator: '-',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Lists'),
|
2012-03-21 13:20:22 +00:00
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 64
|
2012-03-21 13:20:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'groups',
|
|
|
|
operator: '+',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Groups'),
|
2012-03-21 13:20:22 +00:00
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 64
|
2012-03-21 13:20:22 +00:00
|
|
|
},
|
2011-10-03 09:31:20 +00:00
|
|
|
{
|
|
|
|
id: 'screensize',
|
|
|
|
align: 'right',
|
|
|
|
operator: '-',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Screen Size'),
|
2011-10-03 09:31:20 +00:00
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 80
|
2011-10-03 09:31:20 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
id: 'windowsize',
|
|
|
|
operator: '-',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Window Size'),
|
2011-10-03 09:31:20 +00:00
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 80
|
2011-10-03 09:31:20 +00:00
|
|
|
},
|
2011-12-03 16:17:07 +00:00
|
|
|
{
|
2012-03-21 13:07:19 +00:00
|
|
|
align: 'right',
|
|
|
|
id: 'ip',
|
2011-12-03 16:17:07 +00:00
|
|
|
operator: '+',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('IP Address'),
|
2011-12-03 16:17:07 +00:00
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 128
|
2011-12-03 16:17:07 +00:00
|
|
|
},
|
2011-10-03 09:31:20 +00:00
|
|
|
{
|
|
|
|
id: 'useragent',
|
2011-10-03 16:38:07 +00:00
|
|
|
operator: '+',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('User Agent'),
|
2011-10-03 09:31:20 +00:00
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 768
|
2011-10-03 09:31:20 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
columnsRemovable: true,
|
|
|
|
columnsVisible: true,
|
2012-06-20 10:47:15 +00:00
|
|
|
items: pandora.api.findUsers,
|
|
|
|
query: {
|
|
|
|
conditions: [
|
|
|
|
{key: 'level', value: 'guest', operator: '!='},
|
|
|
|
{key: 'level', value: 'robot', operator: '!='}
|
|
|
|
],
|
|
|
|
operator: '&'
|
2012-02-05 11:19:40 +00:00
|
|
|
},
|
2012-01-13 09:47:18 +00:00
|
|
|
keys: ['notes', 'groups'],
|
2011-12-18 09:27:15 +00:00
|
|
|
max: -1,
|
2011-10-03 09:31:20 +00:00
|
|
|
scrollbarVisible: true,
|
2012-06-27 22:24:02 +00:00
|
|
|
sort: [{key: 'lastseen', operator: '-'}],
|
|
|
|
unique: 'id'
|
2011-10-03 09:31:20 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
init: function(data) {
|
2012-02-17 13:50:06 +00:00
|
|
|
numberOfUsers = data.users;
|
2011-10-11 16:13:21 +00:00
|
|
|
$status.html(
|
2011-11-07 14:46:16 +00:00
|
|
|
Ox.formatNumber(data.items)
|
|
|
|
+ ' user' + (data.items == 1 ? '' : 's')
|
2011-11-12 11:02:54 +00:00
|
|
|
+ (
|
|
|
|
$guestsCheckbox.value()
|
|
|
|
? ' (' + Ox.formatNumber(data.users) + ' registered, '
|
|
|
|
+ Ox.formatNumber(data.guests) + ' guest'
|
2013-07-19 10:09:21 +00:00
|
|
|
+ (data.guests == 1 ? '' : 's')
|
|
|
|
+ (
|
|
|
|
$robotsCheckbox.value()
|
|
|
|
? ', '
|
|
|
|
+ Ox.formatNumber(data.robots) + ' robot'
|
|
|
|
+ (data.robots == 1 ? '' : 's')
|
|
|
|
: ''
|
|
|
|
) + ')'
|
2011-11-12 11:02:54 +00:00
|
|
|
: ''
|
|
|
|
)
|
2011-10-11 16:13:21 +00:00
|
|
|
);
|
2011-10-03 09:31:20 +00:00
|
|
|
},
|
2013-01-01 13:10:41 +00:00
|
|
|
load: function() {
|
|
|
|
$reloadButton.options({disabled: false});
|
|
|
|
},
|
2011-12-18 09:27:15 +00:00
|
|
|
select: selectUsers
|
2011-10-03 09:31:20 +00:00
|
|
|
}),
|
|
|
|
|
2011-12-18 09:27:15 +00:00
|
|
|
$formButton = Ox.ButtonGroup({
|
|
|
|
buttons: [
|
2011-10-03 01:46:19 +00:00
|
|
|
{
|
2011-12-18 09:27:15 +00:00
|
|
|
id: 'edit',
|
|
|
|
selected: true,
|
|
|
|
title: 'edit',
|
2013-05-09 10:13:58 +00:00
|
|
|
tooltip: Ox._('Edit')
|
2011-09-24 23:09:48 +00:00
|
|
|
},
|
2011-10-03 01:46:19 +00:00
|
|
|
{
|
2011-12-18 09:27:15 +00:00
|
|
|
id: 'mail',
|
|
|
|
title: 'mail',
|
2013-05-09 10:13:58 +00:00
|
|
|
tooltip: Ox._('Mail')
|
2011-12-18 09:27:15 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
selectable: true,
|
|
|
|
type: 'image'
|
|
|
|
})
|
2013-08-02 20:29:09 +00:00
|
|
|
.css({float: 'left', margin: '4px 2px 4px 4px'})
|
2011-12-18 09:27:15 +00:00
|
|
|
.bindEvent({
|
|
|
|
change: selectForm
|
|
|
|
}),
|
|
|
|
|
2013-08-02 20:29:09 +00:00
|
|
|
$formLabel = Ox.Label({
|
|
|
|
textAlign: 'center',
|
|
|
|
title: Ox._('No user selected'),
|
|
|
|
width: 192
|
|
|
|
})
|
|
|
|
.css({float: 'left', margin: '4px 2px'}),
|
|
|
|
|
|
|
|
$deselectButton = Ox.Button({
|
|
|
|
disabled: true,
|
|
|
|
title: 'close',
|
|
|
|
tooltip: Ox._('Done'),
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'left', margin: '4px 4px 4px 2px'})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
$list.options({selected: []});
|
|
|
|
selectUsers({ids: []});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
2013-03-24 09:39:43 +00:00
|
|
|
$form = Ox.Element(),
|
2011-12-18 09:27:15 +00:00
|
|
|
|
|
|
|
$editForm,
|
|
|
|
|
2012-03-21 05:16:13 +00:00
|
|
|
$sendButton = Ox.Button({
|
|
|
|
disabled: true,
|
|
|
|
id: 'send',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Send'),
|
2012-03-21 05:16:13 +00:00
|
|
|
width: 64
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: sendMail
|
|
|
|
}),
|
|
|
|
|
2011-12-18 09:27:15 +00:00
|
|
|
$mailForm = renderMailForm(),
|
|
|
|
|
|
|
|
$content = Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: Ox.Bar({size: 24})
|
2012-03-20 07:19:03 +00:00
|
|
|
.append($reloadButton)
|
2011-12-18 09:27:15 +00:00
|
|
|
.append($guestsCheckbox)
|
2012-04-19 09:52:36 +00:00
|
|
|
.append($robotsCheckbox)
|
2011-12-18 09:27:15 +00:00
|
|
|
.append($findElement),
|
|
|
|
size: 24
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: $list
|
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
|
|
|
})
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: Ox.SplitPanel({
|
2011-10-03 01:46:19 +00:00
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: Ox.Bar({size: 24})
|
2013-08-02 20:29:09 +00:00
|
|
|
.append($formButton)
|
2011-12-18 09:27:15 +00:00
|
|
|
.append($formLabel)
|
2013-08-02 20:29:09 +00:00
|
|
|
.append($deselectButton),
|
2011-10-03 01:46:19 +00:00
|
|
|
size: 24
|
|
|
|
},
|
|
|
|
{
|
2011-12-18 09:27:15 +00:00
|
|
|
element: $form
|
2011-10-03 01:46:19 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
2011-12-18 09:27:15 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
resize: setWidth
|
2011-10-03 01:46:19 +00:00
|
|
|
}),
|
2011-12-18 09:27:15 +00:00
|
|
|
resizable: true,
|
|
|
|
resize: [256, 384, 512],
|
|
|
|
size: 256
|
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'horizontal'
|
|
|
|
}),
|
|
|
|
|
|
|
|
that = Ox.Dialog({
|
|
|
|
buttons: [
|
2012-03-23 08:55:22 +00:00
|
|
|
Ox.Button({
|
|
|
|
id: 'statistics',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Statistics...')
|
2012-03-23 08:55:22 +00:00
|
|
|
}).bindEvent({
|
|
|
|
click: function() {
|
2012-03-23 09:02:55 +00:00
|
|
|
that.close();
|
|
|
|
pandora.$ui.statisticsDialog = pandora.ui.statisticsDialog().open();
|
2012-03-23 08:55:22 +00:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
{},
|
2011-12-18 09:27:15 +00:00
|
|
|
Ox.Button({
|
2013-08-14 18:22:12 +00:00
|
|
|
title: Ox._('Export E-Mail Addresses...')
|
2011-12-18 09:27:15 +00:00
|
|
|
})
|
|
|
|
.css({margin: '4px 4px 4px 0'})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
2013-08-14 18:22:12 +00:00
|
|
|
var $button = this;
|
|
|
|
$button.options({disabled: true});
|
2011-12-18 09:27:15 +00:00
|
|
|
pandora.api.findUsers({
|
|
|
|
query: {conditions: [], operator: '&'},
|
|
|
|
keys: ['email', 'username'],
|
|
|
|
range: [0, numberOfUsers],
|
|
|
|
sort: [{key: 'username', operator: '+'}]
|
|
|
|
}, function(result) {
|
2013-08-14 18:22:12 +00:00
|
|
|
pandora.ui.exportDialog({
|
|
|
|
data: result.data.items.filter(function(item) {
|
|
|
|
return item.email;
|
|
|
|
}).map(function(item) {
|
|
|
|
return Ox.encodeHTMLEntities(item.username)
|
|
|
|
+ ' <' + item.email + '>';
|
|
|
|
}).join(', '),
|
|
|
|
title: Ox._('E-Mail Addresses')
|
|
|
|
}).open();
|
|
|
|
$button.options({disabled: false});
|
2011-12-18 09:27:15 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Ox.Button({
|
|
|
|
id: 'done',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Done'),
|
2011-12-18 09:27:15 +00:00
|
|
|
width: 48
|
|
|
|
}).bindEvent({
|
|
|
|
click: function() {
|
|
|
|
that.close();
|
|
|
|
}
|
|
|
|
})
|
2011-10-03 01:46:19 +00:00
|
|
|
],
|
2011-12-18 09:27:15 +00:00
|
|
|
closeButton: true,
|
|
|
|
content: $content,
|
|
|
|
height: dialogHeight,
|
|
|
|
maximizeButton: true,
|
|
|
|
minHeight: 256,
|
|
|
|
minWidth: 512,
|
|
|
|
padding: 0,
|
|
|
|
removeOnClose: true,
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Manage Users'),
|
2011-12-18 09:27:15 +00:00
|
|
|
width: dialogWidth
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
resize: setHeight
|
2011-10-03 01:46:19 +00:00
|
|
|
}),
|
2011-10-11 16:13:21 +00:00
|
|
|
|
|
|
|
$status = $('<div>')
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
top: '4px',
|
2012-03-23 08:55:22 +00:00
|
|
|
left: '128px',
|
|
|
|
right: '384px',
|
2011-10-11 16:13:21 +00:00
|
|
|
bottom: '4px',
|
|
|
|
paddingTop: '2px',
|
|
|
|
fontSize: '9px',
|
2012-03-23 08:55:22 +00:00
|
|
|
textAlign: 'center'
|
2011-10-11 16:13:21 +00:00
|
|
|
})
|
2012-05-22 13:15:16 +00:00
|
|
|
.appendTo(that.find('.OxButtonsbar'));
|
2011-10-11 16:13:21 +00:00
|
|
|
|
2012-03-19 15:57:36 +00:00
|
|
|
that.superClose = that.close;
|
|
|
|
that.close = function() {
|
|
|
|
Ox.Request.clearCache('findUsers');
|
|
|
|
that.superClose();
|
|
|
|
};
|
|
|
|
|
2011-12-18 09:27:15 +00:00
|
|
|
function getFormItemById(id) {
|
|
|
|
var ret;
|
|
|
|
Ox.forEach((
|
|
|
|
$formButton.value() == 'edit' ? $editForm : $mailForm
|
|
|
|
).options('items'), function($item) {
|
|
|
|
if ($item.options('id') == id) {
|
|
|
|
ret = $item;
|
2012-07-04 11:40:37 +00:00
|
|
|
return false;
|
2011-12-18 09:27:15 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
|
2014-02-12 11:40:02 +00:00
|
|
|
function getTo(callback) {
|
|
|
|
pandora.api.findUsers({
|
|
|
|
query: {conditions: [
|
|
|
|
{key: 'level', value: 'guest', operator: '!='},
|
|
|
|
{key: 'level', value: 'robot', operator: '!='}
|
|
|
|
], operator: '&'},
|
|
|
|
keys: ['id', 'username', 'newsletter'],
|
|
|
|
range: [0, numberOfUsers],
|
|
|
|
sort: [{key: 'username', operator: '+'}]
|
|
|
|
}, function(result) {
|
|
|
|
var selected = $list.options('selected');
|
|
|
|
callback(result.data.items.filter(function(user) {
|
|
|
|
return selected.indexOf(user.id) > -1
|
|
|
|
&& ($mailForm.values().include == 'users' || user.newsletter);
|
|
|
|
}).map(function(user) {
|
|
|
|
return user.username;
|
|
|
|
}));
|
2011-12-18 09:27:15 +00:00
|
|
|
});
|
|
|
|
}
|
2011-10-03 09:31:20 +00:00
|
|
|
|
2011-12-18 09:27:15 +00:00
|
|
|
function renderEditForm() {
|
|
|
|
var user = $list.value($list.options('selected')[0]);
|
2011-10-03 09:31:20 +00:00
|
|
|
return Ox.Form({
|
2011-12-18 09:27:15 +00:00
|
|
|
items: [
|
|
|
|
Ox.Checkbox({
|
|
|
|
id: 'status',
|
2013-05-10 14:54:30 +00:00
|
|
|
label: Ox._('Status'),
|
2011-12-18 09:27:15 +00:00
|
|
|
labelWidth: 80,
|
2013-05-10 14:54:30 +00:00
|
|
|
title: !user.disabled ? Ox._('Enabled') : Ox._('Disabled'),
|
2011-12-22 15:48:48 +00:00
|
|
|
value: !user.disabled,
|
2011-12-18 09:27:15 +00:00
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
this.options({
|
2013-05-10 14:54:30 +00:00
|
|
|
title: this.options('title') == Ox._('Enabled')
|
|
|
|
? Ox._('Disabled') : Ox._('Enabled')
|
2011-12-18 09:27:15 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Ox.Input({
|
|
|
|
id: 'username',
|
2013-05-10 14:54:30 +00:00
|
|
|
label: Ox._('Username'),
|
2011-12-18 09:27:15 +00:00
|
|
|
labelWidth: 80,
|
|
|
|
value: user.username,
|
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
submit: function(data) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Ox.Input({
|
|
|
|
id: 'email',
|
2013-05-10 14:54:30 +00:00
|
|
|
label: Ox._('E-Mail'),
|
2011-12-18 09:27:15 +00:00
|
|
|
labelWidth: 80,
|
|
|
|
value: user.email,
|
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
submit: function(data) {
|
2011-10-03 15:01:47 +00:00
|
|
|
|
2011-12-18 09:27:15 +00:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
Ox.Select({
|
|
|
|
id: 'level',
|
2012-05-22 15:07:34 +00:00
|
|
|
items: pandora.site.userLevels.slice(1).map(function(level) {
|
|
|
|
return {
|
2011-12-18 09:27:15 +00:00
|
|
|
id: level,
|
|
|
|
title: Ox.toTitleCase(level)
|
2012-05-22 15:07:34 +00:00
|
|
|
};
|
2011-12-18 09:27:15 +00:00
|
|
|
}),
|
2013-05-10 14:54:30 +00:00
|
|
|
label: Ox._('Level'),
|
2011-12-18 09:27:15 +00:00
|
|
|
labelWidth: 80,
|
2011-12-22 15:48:48 +00:00
|
|
|
value: user.level,
|
2011-12-18 09:27:15 +00:00
|
|
|
width: formWidth - 16
|
|
|
|
}),
|
|
|
|
Ox.Checkbox({
|
|
|
|
id: 'newsletter',
|
2013-05-10 14:54:30 +00:00
|
|
|
label: Ox._('Newsletter'),
|
2011-10-03 15:01:47 +00:00
|
|
|
labelWidth: 80,
|
2013-05-10 14:54:30 +00:00
|
|
|
title: user.newsletter ? Ox._('Subscribed') : Ox._('Unsubscribed'),
|
2011-12-22 15:48:48 +00:00
|
|
|
value: user.newsletter,
|
2011-12-18 09:27:15 +00:00
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
this.options({
|
2013-05-10 14:54:30 +00:00
|
|
|
title: this.options('title') == Ox._('Subscribed')
|
|
|
|
? Ox._('Unsubscribed') : Ox._('Subscribed')
|
2011-12-18 09:27:15 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
2012-03-21 13:20:22 +00:00
|
|
|
Ox.Input({
|
|
|
|
id: 'groups',
|
2013-05-10 14:54:30 +00:00
|
|
|
label: Ox._('Groups'),
|
2012-03-21 13:20:22 +00:00
|
|
|
labelWidth: 80,
|
|
|
|
value: user.groups ? user.groups.join(', ') : '',
|
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
submit: function(data) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}),
|
2011-12-18 09:27:15 +00:00
|
|
|
Ox.Input({
|
2012-01-19 16:35:28 +00:00
|
|
|
height: dialogHeight - 184,
|
2011-12-18 09:27:15 +00:00
|
|
|
id: 'notes',
|
2013-05-10 14:54:30 +00:00
|
|
|
placeholder: Ox._('Notes'),
|
2011-12-18 09:27:15 +00:00
|
|
|
type: 'textarea',
|
|
|
|
value: user.notes,
|
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
],
|
|
|
|
width: 240
|
|
|
|
})
|
|
|
|
.css({margin: '8px'})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(event) {
|
|
|
|
var data = {id: user.id}, key, value;
|
|
|
|
if (event.id == 'status') {
|
2011-12-21 15:34:28 +00:00
|
|
|
data.disabled = !event.data.value;
|
2011-12-18 09:27:15 +00:00
|
|
|
} else if (event.id == 'level') {
|
2011-12-21 15:34:28 +00:00
|
|
|
data.level = event.data.value;
|
2011-12-18 09:27:15 +00:00
|
|
|
} else if (event.id == 'newsletter') {
|
2011-12-21 15:34:28 +00:00
|
|
|
data.newsletter = event.data.value;
|
2012-01-13 09:47:18 +00:00
|
|
|
} else if (event.id == 'groups') {
|
|
|
|
data.groups = event.data.value.split(', ');
|
2011-12-18 09:27:15 +00:00
|
|
|
} else {
|
|
|
|
data[event.id] = event.data.value;
|
|
|
|
}
|
2012-04-22 10:33:31 +00:00
|
|
|
if (event.id == 'status') {
|
|
|
|
$list.value(user.id, 'disabled', data.disabled);
|
|
|
|
} else {
|
|
|
|
$list.value(user.id, event.id, data[event.id]);
|
|
|
|
}
|
2011-12-18 09:27:15 +00:00
|
|
|
pandora.api.editUser(data, function(result) {
|
|
|
|
Ox.Request.clearCache('findUsers');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderMailForm() {
|
|
|
|
return Ox.Form({
|
|
|
|
items: [
|
|
|
|
Ox.Input({
|
|
|
|
disabled: true,
|
|
|
|
id: 'from',
|
2013-05-10 15:15:07 +00:00
|
|
|
label: Ox._('From'),
|
2011-12-18 09:27:15 +00:00
|
|
|
labelWidth: 80,
|
|
|
|
value: pandora.site.site.name + ' <' + pandora.site.site.email.contact + '>',
|
|
|
|
width: formWidth - 16
|
|
|
|
}),
|
|
|
|
Ox.Input({
|
|
|
|
disabled: true,
|
|
|
|
id: 'to',
|
2013-05-10 14:54:30 +00:00
|
|
|
label: Ox._('To'),
|
2011-12-18 09:27:15 +00:00
|
|
|
labelWidth: 80,
|
|
|
|
value: '',
|
|
|
|
width: formWidth - 16
|
|
|
|
}),
|
|
|
|
Ox.Select({
|
|
|
|
id: 'include',
|
|
|
|
items: [
|
2013-05-09 10:13:58 +00:00
|
|
|
{id: 'users', title: Ox._('All users')},
|
|
|
|
{id: 'subscribers', title: Ox._('Subscribers only')},
|
2011-12-18 09:27:15 +00:00
|
|
|
],
|
2013-05-10 14:54:30 +00:00
|
|
|
label: Ox._('Include'),
|
2011-12-18 09:27:15 +00:00
|
|
|
labelWidth: 80,
|
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function() {
|
2014-02-12 11:40:02 +00:00
|
|
|
setTo(setSend);
|
2011-12-18 09:27:15 +00:00
|
|
|
}
|
2011-10-03 09:31:20 +00:00
|
|
|
}),
|
2011-12-18 09:27:15 +00:00
|
|
|
Ox.Input({
|
|
|
|
id: 'subject',
|
2013-05-10 14:54:30 +00:00
|
|
|
label: Ox._('Subject'),
|
2011-12-18 09:27:15 +00:00
|
|
|
labelWidth: 80,
|
|
|
|
value: pandora.site.site.email.prefix + ' ',
|
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: setSend
|
2011-10-03 09:31:20 +00:00
|
|
|
}),
|
2011-12-18 09:27:15 +00:00
|
|
|
Ox.Input({
|
|
|
|
height: dialogHeight - 208,
|
|
|
|
id: 'message',
|
2013-05-10 14:54:30 +00:00
|
|
|
placeholder: Ox._('Message'),
|
2011-10-03 09:31:20 +00:00
|
|
|
type: 'textarea',
|
2011-12-18 09:27:15 +00:00
|
|
|
value: '\n\n' + pandora.site.site.email.footer,
|
|
|
|
width: formWidth - 16
|
2011-10-03 09:31:20 +00:00
|
|
|
})
|
2011-12-18 09:27:15 +00:00
|
|
|
.bindEvent({
|
|
|
|
change: setSend
|
|
|
|
}),
|
2011-12-20 07:20:23 +00:00
|
|
|
Ox.MenuButton({
|
2011-12-18 09:27:15 +00:00
|
|
|
id: 'insert',
|
|
|
|
items: [
|
2013-05-09 10:13:58 +00:00
|
|
|
{id: 'username', title: Ox._('Username')},
|
2013-05-20 19:14:57 +00:00
|
|
|
{id: 'email', title: Ox._('E-Mail Address')},
|
2011-12-18 09:27:15 +00:00
|
|
|
],
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Insert...'),
|
2011-12-18 09:27:15 +00:00
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function(data) {
|
|
|
|
var $input = getFormItemById('message'),
|
|
|
|
textarea = $input.find('textarea')[0],
|
2011-12-21 15:34:28 +00:00
|
|
|
value = $input.value();
|
|
|
|
$input.value(
|
2012-05-24 09:56:52 +00:00
|
|
|
value.slice(0, textarea.selectionStart)
|
2011-12-21 15:34:28 +00:00
|
|
|
+ '{' + data.id + '}'
|
2012-05-24 09:56:52 +00:00
|
|
|
+ value.slice(textarea.selectionEnd)
|
2011-12-21 15:34:28 +00:00
|
|
|
)
|
2011-12-18 09:27:15 +00:00
|
|
|
.focusInput(textarea.selectionStart + data.id.length + 2);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Ox.Checkbox({
|
|
|
|
id: 'receipt',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Send a receipt to {0}', [pandora.user.email]),
|
2011-12-22 15:48:48 +00:00
|
|
|
value: false,
|
2011-12-18 09:27:15 +00:00
|
|
|
width: formWidth - 16
|
|
|
|
}),
|
2012-03-21 05:16:13 +00:00
|
|
|
$sendButton
|
2011-12-18 09:27:15 +00:00
|
|
|
],
|
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
.css({margin: '8px', textAlign: 'right'});
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectForm(data) {
|
|
|
|
var selected;
|
2011-12-21 15:34:28 +00:00
|
|
|
if (data.value == 'edit') {
|
2011-12-18 09:27:15 +00:00
|
|
|
$mailForm.detach();
|
|
|
|
selected = $list.options('selected');
|
2012-03-26 19:27:20 +00:00
|
|
|
if (selected.length == 1 && ['guest', 'robot'].indexOf(selected[0].level) == -1) {
|
2011-12-18 09:27:15 +00:00
|
|
|
$form.append($editForm = renderEditForm());
|
|
|
|
}
|
|
|
|
} else {
|
2014-02-12 11:40:02 +00:00
|
|
|
setTo(setSend);
|
2011-12-18 09:27:15 +00:00
|
|
|
setWidth();
|
|
|
|
$editForm && $editForm.remove();
|
|
|
|
$form.append($mailForm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectUsers(data) {
|
2012-06-30 14:58:21 +00:00
|
|
|
var users = data.ids.map(function(id) {
|
2011-12-18 09:27:15 +00:00
|
|
|
return $list.value(id);
|
|
|
|
});
|
|
|
|
setLabel();
|
2013-08-02 20:29:09 +00:00
|
|
|
$deselectButton.options({disabled: data.ids.length == 0});
|
2011-12-18 09:27:15 +00:00
|
|
|
if ($formButton.value() == 'edit') {
|
|
|
|
$form.empty();
|
2012-06-30 14:58:21 +00:00
|
|
|
if (
|
|
|
|
data.ids.length == 1
|
|
|
|
&& ['guest', 'robot'].indexOf(users[0].level) == -1
|
|
|
|
) {
|
|
|
|
$form.append($editForm = renderEditForm());
|
2011-12-18 09:27:15 +00:00
|
|
|
}
|
|
|
|
} else {
|
2014-02-12 11:40:02 +00:00
|
|
|
setTo(setSend);
|
2011-12-18 09:27:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function sendMail() {
|
2013-05-09 10:13:58 +00:00
|
|
|
$sendButton.options({title: Ox._('Sending'), disabled: true});
|
2014-02-12 11:40:02 +00:00
|
|
|
getTo(function(to) {
|
|
|
|
pandora.api.mail({
|
|
|
|
to: to,
|
|
|
|
subject: getFormItemById('subject').value(),
|
|
|
|
message: getFormItemById('message').value(),
|
|
|
|
receipt: getFormItemById('receipt').value()
|
|
|
|
}, function(result) {
|
|
|
|
var $dialog = pandora.ui.iconDialog({
|
|
|
|
buttons: [
|
|
|
|
Ox.Button({
|
|
|
|
id: 'close',
|
|
|
|
title: Ox._('Close')
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
$dialog.close();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
],
|
|
|
|
content: result.status.code == 200
|
|
|
|
? Ox._('Your message has been sent.')
|
|
|
|
: Ox._('Your message could not be sent. Please try again.'),
|
|
|
|
keys: {enter: 'close', escape: 'close'},
|
|
|
|
title: result.status.code == 200
|
|
|
|
? Ox._('Message Sent')
|
|
|
|
: Ox._('Application Error')
|
|
|
|
}).open();
|
|
|
|
$sendButton.options({title: Ox._('Send'), disabled: false});
|
|
|
|
});
|
2011-12-18 09:27:15 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setHeight(data) {
|
2011-12-21 15:34:28 +00:00
|
|
|
var form = $formButton.value(),
|
2011-12-18 09:27:15 +00:00
|
|
|
$item = getFormItemById(form == 'edit' ? 'notes' : 'message');
|
|
|
|
dialogHeight = data.height;
|
|
|
|
$item && $item.options({
|
|
|
|
height: dialogHeight - (form == 'edit' ? 160 : 208)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setLabel() {
|
|
|
|
var users = $list.options('selected').map(function(id) {
|
|
|
|
return $list.value(id);
|
|
|
|
}),
|
2013-05-09 10:13:58 +00:00
|
|
|
title = users.length == 0 ? Ox._('No user selected')
|
2011-12-18 09:27:15 +00:00
|
|
|
: users.length == 1 ? (
|
2012-03-26 19:27:20 +00:00
|
|
|
['guest', 'robot'].indexOf(users[0].level) > -1
|
|
|
|
? Ox.toTitleCase(users[0].level)
|
2012-02-22 10:14:07 +00:00
|
|
|
: Ox.encodeHTMLEntities(users[0].username)
|
|
|
|
+ ' <' + users[0].email + '>'
|
2011-12-18 09:27:15 +00:00
|
|
|
)
|
2013-05-09 10:13:58 +00:00
|
|
|
: Ox._('{0} users selected', [users.length]);
|
2011-12-18 09:27:15 +00:00
|
|
|
$formLabel.options({title: title});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setSend() {
|
|
|
|
getFormItemById('send').options({
|
2013-05-09 10:13:58 +00:00
|
|
|
disabled: getFormItemById('to').value() == Ox._('No recipients')
|
2011-12-21 15:34:28 +00:00
|
|
|
|| getFormItemById('subject').value() === ''
|
|
|
|
|| getFormItemById('message').value() === ''
|
2011-12-18 09:27:15 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-02-12 11:40:02 +00:00
|
|
|
function setTo(callback) {
|
|
|
|
getTo(function(to) {
|
|
|
|
var recipients = to.length;
|
|
|
|
$mailForm.values({
|
|
|
|
to: Ox.formatCount(recipients, 'recipient').replace('no', 'No')
|
|
|
|
});
|
|
|
|
callback();
|
2011-12-18 09:27:15 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setWidth() {
|
2012-03-23 08:55:22 +00:00
|
|
|
var $form = $formButton.value() == 'edit' ? $editForm : $mailForm;
|
2011-12-18 09:27:15 +00:00
|
|
|
formWidth = $content.size(1);
|
2013-08-02 20:29:09 +00:00
|
|
|
$formLabel.options({width: formWidth - 64});
|
2012-03-23 08:55:22 +00:00
|
|
|
$form && $form.options('items').forEach(function($item) {
|
2011-12-18 09:27:15 +00:00
|
|
|
if ($item.options('id') != 'send') {
|
|
|
|
$item.options({width: formWidth - 16});
|
|
|
|
}
|
|
|
|
});
|
2012-03-23 08:55:22 +00:00
|
|
|
$status.css({right: formWidth + 128 + 'px'});
|
2011-10-03 09:31:20 +00:00
|
|
|
}
|
|
|
|
|
2011-11-12 11:02:54 +00:00
|
|
|
function updateList() {
|
|
|
|
var guests = $guestsCheckbox.value(),
|
2012-04-19 09:52:36 +00:00
|
|
|
robots = $robotsCheckbox.value(),
|
2011-11-12 11:02:54 +00:00
|
|
|
key = $findSelect.value(),
|
|
|
|
value = $findInput.value(),
|
|
|
|
query = {
|
|
|
|
conditions: value
|
2012-05-24 08:22:56 +00:00
|
|
|
? [].concat(
|
2014-09-30 12:26:14 +00:00
|
|
|
Ox.contains(['username', 'all'], key) ? [{key: 'username', value: value, operator: '='}] : [],
|
|
|
|
Ox.contains(['email', 'all'], key) ? [{key: 'email', value: value, operator: '='}] : [],
|
|
|
|
Ox.contains(['group', 'all'], key) ? [{key: 'group', value: value, operator: '='}] : []
|
2011-11-12 11:02:54 +00:00
|
|
|
)
|
2012-05-24 08:22:56 +00:00
|
|
|
: [].concat(
|
2012-04-19 09:52:36 +00:00
|
|
|
!guests ? [{key: 'level', value: 'guest', operator: '!='}] : [],
|
|
|
|
!robots ? [{key: 'level', value: 'robot', operator: '!='}] : []
|
|
|
|
),
|
2011-11-12 11:02:54 +00:00
|
|
|
operator: key == 'all' && value ? '|' : '&'
|
2011-10-03 09:31:20 +00:00
|
|
|
};
|
2013-03-24 09:39:43 +00:00
|
|
|
$list.options({query: query});
|
2011-10-03 09:31:20 +00:00
|
|
|
}
|
|
|
|
|
2011-09-24 23:09:48 +00:00
|
|
|
return that;
|
2011-10-03 09:31:20 +00:00
|
|
|
|
2011-09-24 23:09:48 +00:00
|
|
|
};
|
|
|
|
|