Commit c66ae4aa authored by Gabriel Detraz's avatar Gabriel Detraz
Browse files

Propose au cableur de synchroniser le champ mailExt et le .forward dans le home (via forward.py)

parent 8c78c089
......@@ -16,6 +16,7 @@ import copy
import ldap
import time
import unicodedata
import subprocess
if '/usr/scripts' not in sys.path:
sys.path.append('/usr/scripts')
......@@ -883,21 +884,30 @@ class Dialog(machine.Dialog, blacklist.Dialog):
return (code, tags, make_compte_crans)
def modif_proprio(proprio, attrs):
mailmodif = False
with self.conn.search(dn=proprio.dn, scope=0, mode='rw')[0] as proprio:
for (key, values) in attrs.items():
proprio[key] = values
# On retire les éventuelle bl mail invalide
if key == u'mailExt' or key == u'mail':
for bl in proprio['blacklist']:
now = int(time.time())
if bl['type'] == u'mail_invalide' and bl['fin'] > now:
bl['fin'] = now
if bl['debut'] > now:
bl['debut'] = now
bl['comm'] += u'- mail rectifié'
if key == 'mailExt' and any('mailExt' in element for element in proprio.get_modlist()):
mailmodif = values[0]
# On retire les éventuelle bl mail invalide
if any('mailExt' in element for element in proprio.get_modlist()) or any('mail' in element for element in proprio.get_modlist()):
for bl in proprio['blacklist']:
now = int(time.time())
if bl['type'] == u'mail_invalide' and bl['fin'] > now:
bl['fin'] = now
if bl['debut'] > now:
bl['debut'] = now
bl['comm'] += u'- mail rectifié'
proprio.validate_changes()
proprio.history_gen()
proprio.save()
if mailmodif:
if self.dialog.yesno("L'attribut mailExt a été modifié dans la base ldap, synchroniser le .forward?",
title="Modification de la redirection mail %s %s" % (proprio.get('prenom', [''])[0], proprio["nom"][0]),
timeout=self.timeout
) == self.dialog.DIALOG_OK:
subprocess.Popen(["sudo","-n","-u","%s" % proprio['uid'][0],"/usr/scripts/utils/forward.py", "--write", "--mail=%s" % mailmodif, "--name=%s" % proprio['uid'][0]])
self.dialog.msgbox(
"Modificaton prise en compte avec succès",
title="Modification des informations de %s %s" % (proprio.get('prenom', [''])[0], proprio["nom"][0]),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment