mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-19 05:58:34 +02:00
+13
-4
@@ -6,6 +6,7 @@ from django.template.loader import render_to_string
|
||||
from modoboa.lib import events
|
||||
from modoboa.lib.webutils import static_url
|
||||
|
||||
@events.observe("UserMenuDisplay")
|
||||
def menu(target, user):
|
||||
import views
|
||||
|
||||
@@ -31,16 +32,24 @@ def menu(target, user):
|
||||
}
|
||||
]
|
||||
|
||||
@events.observe("GetAnnouncement")
|
||||
def announcement(target):
|
||||
if target == "loginpage":
|
||||
txt = render_to_string("demo/login_announcement.html")
|
||||
return [txt]
|
||||
return ""
|
||||
|
||||
@events.observe("PasswordChange")
|
||||
def password_change(user):
|
||||
return [user.id == 1]
|
||||
|
||||
if 'modoboa.demo' in settings.INSTALLED_APPS:
|
||||
events.register("UserMenuDisplay", menu)
|
||||
events.register("GetAnnouncement", announcement)
|
||||
events.register("PasswordChange", password_change)
|
||||
@events.observe("GetStaticContent")
|
||||
def get_static_content(user):
|
||||
if not user.has_mailbox:
|
||||
return []
|
||||
return """<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$(document).on('click', 'a[name=sendspam]', simple_ajax_request);
|
||||
$(document).on('click', 'a[name=sendvirus]', simple_ajax_request);
|
||||
});
|
||||
</script>"""
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
{% load i18n libextras amextras %}
|
||||
<html lang="en">
|
||||
<!DOCTYPE html>{% load i18n libextras amextras %}
|
||||
<html lang="{{ LANGUAGE_CODE }}">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Modoboa</title>
|
||||
@@ -10,17 +9,15 @@
|
||||
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}amavis_quarantine/css/selfservice.css" />
|
||||
<script src="{{ MEDIA_URL }}js/jquery.js" type="text/javascript"></script>
|
||||
<script src="{{ MEDIA_URL }}js/bootstrap.js" type="text/javascript"></script>
|
||||
<script src="{{ MEDIA_URL }}js/utils.js" type="text/javascript"></script>
|
||||
<script src="{{ MEDIA_URL }}js/common.js" type="text/javascript"></script>
|
||||
<script src="{{ MEDIA_URL }}js/global.js" type="text/javascript"></script>
|
||||
<script src="{{ MEDIA_URL }}js/notify.js" type="text/javascript"></script>
|
||||
<script src="{{ MEDIA_URL }}amavis_quarantine/js/selfservice.js" type="text/javascript"></script>
|
||||
{% url django.views.i18n.javascript_catalog as catalog_url %}
|
||||
<script type="text/javascript" src="{{ catalog_url }}"></script>
|
||||
<script type="text/javascript">
|
||||
set_media_url("{{ MEDIA_URL }}");
|
||||
set_media_url("{{ MEDIA_URL }}");
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="fixed_content">
|
||||
<div id="menubar">{% viewm_menu_simple user mail_id rcpt secret_id %}</div>
|
||||
|
||||
@@ -11,6 +11,7 @@ core application and additional components.
|
||||
from functools import wraps
|
||||
import inspect
|
||||
import re
|
||||
from django.conf import settings
|
||||
|
||||
events = [
|
||||
"CanCreate",
|
||||
@@ -114,6 +115,9 @@ class observe(object):
|
||||
return []
|
||||
if not ext.enabled:
|
||||
return []
|
||||
elif not modname in settings.INSTALLED_APPS:
|
||||
return []
|
||||
|
||||
return f(*args)
|
||||
|
||||
map(lambda evt: register(evt, wrapped_f), self.evtnames)
|
||||
|
||||
@@ -1,226 +0,0 @@
|
||||
$(document).ready(function() {
|
||||
$(document).on('click', 'a[data-toggle="ajaxmodal"]', modalbox);
|
||||
$(document).on('click', 'a[data-toggle="ajaxmodal-autowidth"]', modalbox_autowidth);
|
||||
$(document).on('click', 'a[name=sendspam]', simple_ajax_request);
|
||||
$(document).on('click', 'a[name=sendvirus]', simple_ajax_request);
|
||||
});
|
||||
|
||||
var media_url = "";
|
||||
|
||||
/*
|
||||
* A simple function to initialize the value of the global variable
|
||||
* 'media_url' (corresponding to django's MEDIA_URL variable).
|
||||
*/
|
||||
function set_media_url(url) {
|
||||
media_url = url;
|
||||
}
|
||||
|
||||
/*
|
||||
* Shortcut function that construct an url from the media_url and the
|
||||
* given value.
|
||||
*/
|
||||
function static_url(value) {
|
||||
return media_url + value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Easy way to deactivate a link (ie. clicking on it does nothing)
|
||||
*/
|
||||
function disable_link(link) {
|
||||
link.removeEvents("click")
|
||||
.addEvent("click", function(evt) {
|
||||
evt.stop();
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Easy way to re-activate a link that was previously disabled. An
|
||||
* extra argument can be passed to specify a new "click" event
|
||||
* callback.
|
||||
*/
|
||||
function enable_link(link, callback) {
|
||||
link.removeEvents("click");
|
||||
if ($defined(callback)) {
|
||||
link.addEvent("click", callback);
|
||||
}
|
||||
}
|
||||
|
||||
function parse_menubar(id) {
|
||||
var $menubar = $(id);
|
||||
|
||||
if ($menubar == undefined) {
|
||||
return;
|
||||
}
|
||||
$menubar.find('.dropdown-toggle').dropdown();
|
||||
$menubar.find('a[data-toggle="modal"]').click(function(e) {
|
||||
console.log(this);
|
||||
e.preventDefault();
|
||||
var href = $(this).attr('href');
|
||||
|
||||
if (href.indexOf('#') == 0) {
|
||||
$(href).modal('open');
|
||||
} else {
|
||||
$.get(href, function(data) {
|
||||
$('<div class="modal" >' + data + '</div>').modal();
|
||||
}).success(function() {
|
||||
$('input:text:visible:first').focus();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/*.each(function(elem){
|
||||
var list = elem.getElement('ul.links');
|
||||
var myFx = new Fx.Slide(list, {
|
||||
duration: 200
|
||||
});
|
||||
|
||||
var coords = elem.getCoordinates();
|
||||
|
||||
myFx.wrapper.setStyles({
|
||||
position : "absolute",
|
||||
left : coords['left']
|
||||
});
|
||||
myFx.hide();
|
||||
|
||||
elem.addEvents({
|
||||
'mouseenter' : function(evt) {
|
||||
myFx.cancel();
|
||||
myFx.slideIn();
|
||||
},
|
||||
'mouseleave' : function() {
|
||||
myFx.cancel();
|
||||
myFx.slideOut();
|
||||
}
|
||||
});
|
||||
});*/
|
||||
/*SqueezeBox.assign($(id).getElements('a[class=boxed]'), {
|
||||
parse: 'rel'
|
||||
});*/
|
||||
|
||||
};
|
||||
|
||||
get_iframe_body = function(id) {
|
||||
var saf = navigator.userAgent.match(/Safari/i);
|
||||
var safver = (saf ? parseFloat(navigator.userAgent.match(/[\d\.]+Safari/i)) : 0);
|
||||
var targetif = $(id);
|
||||
var data;
|
||||
|
||||
if (targetif.contentDocument && (!saf || (saf && safver >= 3))) {
|
||||
// NS6 & Gecko & Opera & IE7+
|
||||
if (!saf || (saf && safver >= 3)) {
|
||||
data = targetif.contentDocument.defaultView.document.body;
|
||||
} else {
|
||||
data = targetif.document.body;
|
||||
}
|
||||
} else if (targetif.contentWindow && !saf) {
|
||||
// IE 5.5 & 6.x
|
||||
data = targetif.contentWindow.document.body;
|
||||
}
|
||||
return (data);
|
||||
};
|
||||
|
||||
setDivHeight = function(id, extrah, modulo) {
|
||||
var contentsize = $(document.body).getSize().y
|
||||
- $("topmenubar").getSize().y
|
||||
- $("header").getSize().y
|
||||
- $("footer").getSize().y
|
||||
- extrah;
|
||||
|
||||
if (modulo) {
|
||||
contentsize -= contentsize % modulo;
|
||||
}
|
||||
$(id).setStyle("height", contentsize + "px");
|
||||
};
|
||||
|
||||
bindRows = function(rooturl, page) {
|
||||
$$("tr").addEvent("dblclick", function(event) {
|
||||
if (event.target.parentNode.id) {
|
||||
var url = rooturl + "?domid=" + event.target.parentNode.id;
|
||||
if (page != "") {
|
||||
url += "?page=" + page;
|
||||
}
|
||||
event.target.parentNode.setStyle("background", "#ffffcc");
|
||||
location.href = url;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
toggleSelection = function(id, value) {
|
||||
$$("input[name=" + id + "]").each(function(obj) {
|
||||
obj.checked = value;
|
||||
});
|
||||
};
|
||||
|
||||
checkTableSelection = function(text) {
|
||||
if (!$$("tr[class*=table-tr-selected]").length) {
|
||||
return false;
|
||||
}
|
||||
return confirm(text);
|
||||
};
|
||||
|
||||
function searchbox_init() {
|
||||
var myFx = new Fx.Slide($("searchparams"));
|
||||
var $searchfield = $("searchfield");
|
||||
|
||||
myFx.hide();
|
||||
$("searchopts").addEvent("click", function(event) {
|
||||
myFx.cancel();
|
||||
myFx.toggle();
|
||||
});
|
||||
$$("input[name=scriteria]").addEvent("click", function(event) {
|
||||
myFx.cancel();
|
||||
myFx.toggle();
|
||||
});
|
||||
$searchfield.addEvent("change", function(event) {
|
||||
var criteria = "";
|
||||
var pattern = this.get("value");
|
||||
|
||||
$$("input[name=scriteria]:checked").each(function(obj) {
|
||||
criteria = obj.value;
|
||||
});
|
||||
if (pattern != "") {
|
||||
current_anchor.setparams({
|
||||
pattern: pattern,
|
||||
criteria: criteria
|
||||
});
|
||||
} else {
|
||||
current_anchor.deleteParam("pattern");
|
||||
current_anchor.deleteParam("criteria");
|
||||
}
|
||||
current_anchor.update();
|
||||
});
|
||||
$searchfield.addEvent("click", function(event) {
|
||||
$searchfield.select();
|
||||
});
|
||||
|
||||
$searchfield.addEvent("blur", function(event) {
|
||||
if ($searchfield.value == "") {
|
||||
$searchfield.set("value", gettext("Search..."));
|
||||
}
|
||||
});
|
||||
$("searchbox").setStyle("float", "left");
|
||||
var frag = new URI(location.href).get("fragment");
|
||||
if (frag.indexOf('?') != -1) {
|
||||
var params = frag.substring(frag.indexOf('?') + 1).parseQueryString();
|
||||
if ($defined(params.pattern)) {
|
||||
$searchfield.set("value", params.pattern);
|
||||
}
|
||||
if ($defined(params.criteria)) {
|
||||
$("crit_" + params.criteria).checked = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*function saveparams(id, message) {
|
||||
$("#update").click(function(evt) {
|
||||
evt.preventDefault();
|
||||
var $form = $("form");
|
||||
|
||||
$.post($form.attr("action"), $form.serialize(), function(data) {
|
||||
if (data.status == "ok") {
|
||||
$("body").notify("success", message, 2000);
|
||||
}
|
||||
});
|
||||
});
|
||||
};*/
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
/*
|
||||
* Collection of functions that are accessible to every page.
|
||||
* Global javascript utilities
|
||||
*/
|
||||
|
||||
var media_url = "";
|
||||
|
||||
/*
|
||||
* A simple function to initialize the value of the global variable
|
||||
* 'media_url' (corresponding to django's MEDIA_URL variable).
|
||||
*/
|
||||
function set_media_url(url) {
|
||||
media_url = url;
|
||||
}
|
||||
|
||||
function modalbox(e, css, defhref, defcb, defclosecb) {
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
@@ -47,20 +57,6 @@ function modalbox_autowidth(e) {
|
||||
}]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Simple function that redirect ajax requests to the login page if
|
||||
* the status code received with a response is equal to 278.
|
||||
*/
|
||||
function ajax_login_redirect() {
|
||||
if (this.status != 278) {
|
||||
return;
|
||||
}
|
||||
var params = "?next=" + window.location.pathname;
|
||||
|
||||
window.location.href =
|
||||
this.xhr.getResponseHeader("Location").replace(/\?.*$/, params);
|
||||
}
|
||||
|
||||
/*
|
||||
* Simple shorcut do create a bootstrap alert box (error mode)
|
||||
*/
|
||||
@@ -178,35 +174,6 @@ function get_target(e, tag) {
|
||||
return $target.parent();
|
||||
}
|
||||
|
||||
/*
|
||||
* Simple wrapper around Request.JSON. We just ensure that
|
||||
* redirections are correctly catched. (on session timeout for
|
||||
* example)
|
||||
*/
|
||||
// Request.JSON.mdb = new Class({
|
||||
// Extends: Request.JSON,
|
||||
|
||||
// options: {
|
||||
// format: "json",
|
||||
// onComplete: ajax_login_redirect,
|
||||
// onFailure: function(xhr) {
|
||||
// $(document.body).setStyle("overflow", "auto");
|
||||
// $(document.body).set("html", xhr.responseText);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
/*
|
||||
* 'Change password' form initialization.
|
||||
*/
|
||||
function chpasswordform_cb() {
|
||||
$(".submit").one('click', function(e) {
|
||||
simple_ajax_form_post(e, {
|
||||
error_cb: chpasswordform_cb
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a simple AJAX request.
|
||||
*/
|
||||
@@ -224,4 +191,23 @@ function simple_ajax_request(e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Simple function that redirect ajax requests to the login page if
|
||||
* the status code received with a response is equal to 278.
|
||||
*/
|
||||
function ajax_login_redirect() {
|
||||
if (this.status != 278) {
|
||||
return;
|
||||
}
|
||||
var params = "?next=" + window.location.pathname;
|
||||
|
||||
window.location.href =
|
||||
this.xhr.getResponseHeader("Location").replace(/\?.*$/, params);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).on('click', 'a[data-toggle="ajaxmodal"]', modalbox);
|
||||
$(document).on('click', 'a[data-toggle="ajaxmodal-autowidth"]', modalbox_autowidth);
|
||||
});
|
||||
@@ -11,8 +11,7 @@
|
||||
<script src="{{ MEDIA_URL }}js/jquery.js" type="text/javascript"></script>
|
||||
<script src="{{ MEDIA_URL }}js/bootstrap.js" type="text/javascript"></script>
|
||||
<script src="{{ MEDIA_URL }}js/bootstrap-datepicker.js" type="text/javascript"></script>
|
||||
<script src="{{ MEDIA_URL }}js/utils.js" type="text/javascript"></script>
|
||||
<script src="{{ MEDIA_URL }}js/common.js" type="text/javascript"></script>
|
||||
<script src="{{ MEDIA_URL }}js/global.js" type="text/javascript"></script>
|
||||
<script src="{{ MEDIA_URL }}js/confirmation.js" type="text/javascript"></script>
|
||||
<script src="{{ MEDIA_URL }}js/notify.js" type="text/javascript"></script>
|
||||
<script src="{{ MEDIA_URL }}js/poller.js" type="text/javascript"></script>
|
||||
|
||||
+15
-2
@@ -1,7 +1,7 @@
|
||||
# coding: utf-8
|
||||
|
||||
from modoboa.lib import parameters
|
||||
from django.utils.translation import ugettext as _
|
||||
from modoboa.lib import parameters, events
|
||||
from django.utils.translation import ugettext_noop as _
|
||||
|
||||
parameters.register_user("LANG", type="list", deflt="en",
|
||||
label=_("Prefered language"),
|
||||
@@ -9,3 +9,16 @@ parameters.register_user("LANG", type="list", deflt="en",
|
||||
("es", "español"), ("fr", "français")],
|
||||
help=_("Prefered language to display pages"),
|
||||
app="general")
|
||||
|
||||
@events.observe("GetStaticContent")
|
||||
def get_static_content(user):
|
||||
return """<script type="text/javascript">
|
||||
function chpasswordform_cb() {
|
||||
$(".submit").one('click', function(e) {
|
||||
simple_ajax_form_post(e, {
|
||||
formid: "chpasswordform",
|
||||
error_cb: chpasswordform_cb
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>"""
|
||||
|
||||
Reference in New Issue
Block a user