mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-25 05:58:42 +01:00
wip: resellers and limits
I've finally started to rethink the database structure. The goal I'm trying to reach: only use User objects to manage permissions and accesses to the webui and associate other objects to them if needed (like mailboxes). see #105
This commit is contained in:
+26
-1
@@ -26,7 +26,7 @@ input {
|
||||
}
|
||||
|
||||
input[type=text], input[type=password] {
|
||||
width: 140px
|
||||
width: 140px;
|
||||
}
|
||||
|
||||
/*input:hover {
|
||||
@@ -102,6 +102,10 @@ td.even {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#id_username {
|
||||
width: 120px;
|
||||
}
|
||||
@@ -139,6 +143,15 @@ td.even {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
li {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
/*
|
||||
* clearfix related
|
||||
*/
|
||||
@@ -164,3 +177,15 @@ html[xmlns] .clearfix {
|
||||
height: 1%;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
/*
|
||||
* Domain admin form
|
||||
*/
|
||||
#createfrom {
|
||||
margin: 10px auto;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
#permform > #id_name {
|
||||
width: 180px;
|
||||
}
|
||||
@@ -39,9 +39,14 @@ div#footer {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
#adminfo {
|
||||
float: left;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#navbar {
|
||||
float: right;
|
||||
padding: 0;
|
||||
padding: 5px;
|
||||
margin: 0;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ var Confirmation = new Class({
|
||||
}
|
||||
params += item.get("name") + "=true";
|
||||
});
|
||||
new Request.JSON({
|
||||
new Request.JSON.mdb({
|
||||
method: "get",
|
||||
url: Confirmation.url,
|
||||
onSuccess: function(res) {
|
||||
@@ -76,10 +76,7 @@ var Confirmation = new Class({
|
||||
infobox.error(res.respmsg);
|
||||
infobox.hide(2);
|
||||
}
|
||||
},
|
||||
onFailure: function(xhr) {
|
||||
$(parent.document.body).set("html", xhr.responseText);
|
||||
}
|
||||
}
|
||||
}).send(params);
|
||||
},
|
||||
|
||||
|
||||
+194
-56
@@ -1,3 +1,133 @@
|
||||
var Form = new Class({
|
||||
Implements: [Options],
|
||||
|
||||
options: {
|
||||
resptarget: null
|
||||
},
|
||||
|
||||
callbacks: {
|
||||
error: {},
|
||||
success: {},
|
||||
extra_data: {}
|
||||
},
|
||||
|
||||
initialize: function(options) {
|
||||
this.setOptions(options);
|
||||
|
||||
$(document.body)
|
||||
.removeEvents("submit")
|
||||
.addEvent("submit", this.submit.bind(this));
|
||||
|
||||
this.init_help_messages();
|
||||
},
|
||||
|
||||
init_help_messages: function() {
|
||||
$$("input[type!=submit]", "select").addEvents({
|
||||
focus: function(evt) {
|
||||
var helpdiv = $(evt.target.name + "_helptext");
|
||||
if (helpdiv) {
|
||||
var coords = evt.target.getCoordinates();
|
||||
helpdiv.setPosition({x: 10, y: coords['top'] + coords['height'] + 5});
|
||||
helpdiv.setStyle("display", "block");
|
||||
}
|
||||
},
|
||||
blur: function(evt) {
|
||||
var helpdiv = $(evt.target.name + "_helptext");
|
||||
if (helpdiv) {
|
||||
helpdiv.setStyle("display", "none");
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
register_callback: function(category, name, callback) {
|
||||
if (this.callbacks[category][name] == undefined) {
|
||||
return false;
|
||||
}
|
||||
this.callbacks[category][name] = callback;
|
||||
return true;
|
||||
},
|
||||
|
||||
register_error_callback: function(name, callback) {
|
||||
return this.register_callback("error", name, callback);
|
||||
},
|
||||
|
||||
register_success_callback: function(name, callback) {
|
||||
return this.register_callback("success", name, callback);
|
||||
},
|
||||
|
||||
register_extra_data_callback: function(name, callback) {
|
||||
return this.register_callback("extra_data", name, callback);
|
||||
},
|
||||
|
||||
submit: function(event) {
|
||||
var form = event.target;
|
||||
var myid = form.get("id");
|
||||
var data = form.toQueryString();
|
||||
|
||||
console.log("submit");
|
||||
|
||||
event.stop();
|
||||
if (this.callbacks["extra_data"][myid] != undefined) {
|
||||
if (data != "") {
|
||||
data += "&";
|
||||
}
|
||||
data += this.callbacks["extra_data"][myid]();
|
||||
}
|
||||
|
||||
new Request.JSON({
|
||||
url: form.get("action"),
|
||||
method: form.get("method"),
|
||||
data: data,
|
||||
onSuccess: function(response) {
|
||||
if (response.status == "ko") {
|
||||
if (response.norefresh != undefined && response.norefresh == true) {
|
||||
$$("div[class=error]").set("html", response.respmsg);
|
||||
} else {
|
||||
var target = (this.options.target)
|
||||
? $(this.options.target) : $(document.body);
|
||||
|
||||
target.set("html", response.content);
|
||||
this.init_help_messages();
|
||||
/*$(document.body).addEvent("submit", ajax_submit);*/
|
||||
if (this.callbacks["error"][myid] != undefined) {
|
||||
this.callbacks["error"][myid]();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ($defined(response.respmsg)) {
|
||||
if ($defined(parent.current_anchor)) {
|
||||
parent.current_anchor.loading_message = response.respmsg;
|
||||
parent.current_anchor.loading_color = "green";
|
||||
} else {
|
||||
parent.infobox.info(response.respmsg);
|
||||
parent.infobox.hide(1);
|
||||
}
|
||||
}
|
||||
if ($defined(response.ajaxnav)) {
|
||||
if ($defined(response.url)) {
|
||||
parent.current_anchor.baseurl(response.url, 1);
|
||||
}
|
||||
parent.current_anchor.update(1);
|
||||
} else if ($defined(response.url)) {
|
||||
parent.location.href = response.url;
|
||||
}
|
||||
if (this.callbacks["success"][myid] != undefined) {
|
||||
this.callbacks["success"][myid](response);
|
||||
}
|
||||
parent.SqueezeBox.close();
|
||||
}.bind(this),
|
||||
onFailure: function(xhr) {
|
||||
parent.document.getElement('iframe')
|
||||
.setStyles({width: 800, height: 600});
|
||||
$(document.body).set("html", xhr.responseText);
|
||||
}
|
||||
}).send();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var error_callbacks = {
|
||||
permform: function() {
|
||||
if ($defined($("id_domain"))) {
|
||||
@@ -36,70 +166,74 @@ function register_extra_data_callback(name, callback) {
|
||||
}
|
||||
|
||||
function ajax_submit(event) {
|
||||
var form = event.target;
|
||||
var myid = form.get("id");
|
||||
var data = form.toQueryString();
|
||||
var form = event.target;
|
||||
var myid = form.get("id");
|
||||
var data = form.toQueryString();
|
||||
|
||||
event.stop();
|
||||
if ($defined(extra_data_callbacks[myid])) {
|
||||
if (data != "") {
|
||||
data += "&";
|
||||
event.stop();
|
||||
if ($defined(extra_data_callbacks[myid])) {
|
||||
if (data != "") {
|
||||
data += "&";
|
||||
}
|
||||
data += extra_data_callbacks[myid]();
|
||||
}
|
||||
data += extra_data_callbacks[myid]();
|
||||
}
|
||||
|
||||
new Request({
|
||||
method: form.get("method"),
|
||||
data: data,
|
||||
onSuccess: function(responseText){
|
||||
var response = JSON.decode(responseText);
|
||||
new Request.JSON({
|
||||
url: form.get("action"),
|
||||
method: form.get("method"),
|
||||
data: data,
|
||||
onSuccess: function(response) {
|
||||
if (response.status == "ko") {
|
||||
if (response.norefresh != undefined && response.norefresh == true) {
|
||||
$$("div[class=error]").set("html", response.respmsg);
|
||||
} else {
|
||||
var target = (resptarget != undefined)
|
||||
? $(resptarget) : $(document.body);
|
||||
|
||||
if (response.status == "ko") {
|
||||
if ($defined(response.norefresh) && response.norefresh == true) {
|
||||
$("error").set("html", response.respmsg);
|
||||
} else {
|
||||
$(document.body).set("html", response.content);
|
||||
$(document.body).addEvent("submit", ajax_submit);
|
||||
if ($defined(error_callbacks[myid])) {
|
||||
error_callbacks[myid]();
|
||||
}
|
||||
target.set("html", response.content);
|
||||
/*$(document.body).addEvent("submit", ajax_submit);*/
|
||||
if ($defined(error_callbacks[myid])) {
|
||||
error_callbacks[myid]();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ($defined(response.respmsg)) {
|
||||
if ($defined(parent.current_anchor)) {
|
||||
parent.current_anchor.loading_message = response.respmsg;
|
||||
parent.current_anchor.loading_color = "green";
|
||||
} else {
|
||||
parent.infobox.info(response.respmsg);
|
||||
parent.infobox.hide(1);
|
||||
}
|
||||
}
|
||||
if ($defined(response.ajaxnav)) {
|
||||
if ($defined(response.url)) {
|
||||
parent.current_anchor.baseurl(response.url, 1);
|
||||
}
|
||||
parent.current_anchor.update(1);
|
||||
} else if ($defined(response.url)) {
|
||||
parent.location.href = response.url;
|
||||
}
|
||||
if ($defined(success_callbacks[myid])) {
|
||||
success_callbacks[myid](response);
|
||||
}
|
||||
parent.SqueezeBox.close();
|
||||
},
|
||||
onFailure: function(xhr) {
|
||||
parent.document.getElement('iframe').setStyles({width: 800, height: 600});
|
||||
$(document.body).set("html", xhr.responseText);
|
||||
}
|
||||
} else {
|
||||
if ($defined(response.respmsg)) {
|
||||
if ($defined(parent.current_anchor)) {
|
||||
parent.current_anchor.loading_message = response.respmsg;
|
||||
parent.current_anchor.loading_color = "green";
|
||||
} else {
|
||||
parent.infobox.info(response.respmsg);
|
||||
parent.infobox.hide(1);
|
||||
}
|
||||
}
|
||||
if ($defined(response.ajaxnav)) {
|
||||
if ($defined(response.url)) {
|
||||
parent.current_anchor.baseurl(response.url, 1);
|
||||
}
|
||||
parent.current_anchor.update(1);
|
||||
} else if ($defined(response.url)) {
|
||||
parent.location.href = response.url;
|
||||
}
|
||||
if ($defined(success_callbacks[myid])) {
|
||||
success_callbacks[myid](response);
|
||||
}
|
||||
parent.SqueezeBox.close();
|
||||
}
|
||||
},
|
||||
onFailure: function(xhr) {
|
||||
parent.document.getElement('iframe').setStyles({width: 800, height: 600});
|
||||
$(document.body).set("html", xhr.responseText);
|
||||
}
|
||||
}).send();
|
||||
}).send();
|
||||
}
|
||||
|
||||
window.addEvent("domready", function() {
|
||||
$(document.body).addEvent("submit", ajax_submit);
|
||||
function initform() {
|
||||
$(document.body)
|
||||
.removeEvents("submit")
|
||||
.addEvent("submit", ajax_submit);
|
||||
|
||||
$$("input[type!=submit]", "select").addEvents({
|
||||
focus: function(evt) {
|
||||
focus: function(evt) {
|
||||
var helpdiv = $(evt.target.name + "_helptext");
|
||||
if (helpdiv) {
|
||||
var coords = evt.target.getCoordinates();
|
||||
@@ -114,4 +248,8 @@ window.addEvent("domready", function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/*window.addEvent("domready", function() {
|
||||
initform();
|
||||
});*/
|
||||
|
||||
@@ -16,6 +16,10 @@ window.addEvent('domready', function() {
|
||||
}
|
||||
}, $('accordion'));
|
||||
|
||||
SqueezeBox.assign($("content").getElements('a[class=boxed]'), {
|
||||
parse: 'rel'
|
||||
});
|
||||
|
||||
$$("a[name=addperm]").addEvent("click", function(evt) {
|
||||
evt.stop();
|
||||
var sizes = current_sizes.split(" ");
|
||||
|
||||
@@ -25,6 +25,7 @@ Request.JSON.mdb = new Class({
|
||||
Extends: Request.JSON,
|
||||
|
||||
options: {
|
||||
format: "json",
|
||||
onComplete: ajax_login_redirect,
|
||||
onFailure: function(xhr) {
|
||||
$(document.body).setStyle("overflow", "auto");
|
||||
|
||||
Reference in New Issue
Block a user