diff -urN smeserver-zarafa-0.9.0.orig/createlinks smeserver-zarafa-0.9.0/createlinks --- smeserver-zarafa-0.9.0.orig/createlinks 2009-06-01 21:07:05.000000000 +1000 +++ smeserver-zarafa-0.9.0/createlinks 2009-06-01 21:11:39.000000000 +1000 @@ -4,6 +4,9 @@ use File::Basename; use File::Path; +panel_link("zarafaCFG", 'manager'); +panel_link("zarafaUI", 'manager'); + #we use S99 as on first run it must run after S99mysql.init service_link_enhanced("zarafa-gateway", "S99", "7"); service_link_enhanced("zarafa-ical", "S99", "7"); diff -urN smeserver-zarafa-0.9.0.orig/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/zarafaCFG smeserver-zarafa-0.9.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/zarafaCFG --- smeserver-zarafa-0.9.0.orig/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/zarafaCFG 1970-01-01 10:00:00.000000000 +1000 +++ smeserver-zarafa-0.9.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/zarafaCFG 2009-06-01 21:15:33.000000000 +1000 @@ -0,0 +1,223 @@ + + + + ZARAFA_CFG_MANAGEMENT + Configuration + + + + FORM_TITLE + Zarafa mail server configuration + + + + SOFTDELETE + Soft-delete lifetime adjustment + + + + CFG_BUTTON + Server configuration + + + + KEY_BUTTON + Activation/Add a CAL + + + + MYSQL_BUTTON + MySQL adjustment + + + + CACHE_CELL_SIZE + Cache Cell size adjustment + + + + CACHE_OBJECT_SIZE + Cache Object size adjustment + + + + CACHE_INDEX_SIZE + Cache Index size adjustment + + + + QUOTA_WARN + Warning Quota adjustment + + + + QUOTA_SOFT + Soft Quota adjustmen + + + + QUOTA_HARD + Hard Quota adjustmen + + + + COMPANYQUOTA_WARN + Company Quota adjustment + + + + VERSION + Zarafa version : + + + + SYS_AUTH + Database System : + + + + REGISTERED + Registered version + + + + UNREGISTERED + Community version + + + + MAX_USERS + Maximum users : + + + + MODIFY_BUTTON + Modify + + + + CD_KEY + CD-key : + + + + NBRUSERTXT + Maximum users : + + + + CALNAME + CAL file name + + + + CALKEY + Registered CD-Key + + + + CAL_BUTTON + Add a CAL + + + + MODIFY_CONFIG_SUCCESS + Config modified ! + + + + CFG_BUTTON_BUBBLE + Clic here to configure some aspect of Zarafa server + + + + KEY_BUTTON_BUBBLE + Clic here if you want to activate your version of Zarafa or to add some CAL + + + + MYSQL_BUTTON_BUBBLE + Clic here to configure some aspect of MySQL in Zarafa + + + + CAL_BUTTON_BUBBLE + Clic here to add a CAL + + + + INVALID_KEY + Invalid CD-Key. It must be composed by 24 alphanumeric characters. + + + + CREATE_BUTTON + Add a key + + + + EXIST_CALNAME + The filename is already use in another CAL. Please choose another. + + + + EXIST_CALKEY + This key is already use in another CAL. Please enter another. + + + + CAUTION_TIME + CAUTION - This operation may take 1 minutes or more because Zarafa's services must be restarted. + + + + INSERT_CAL_NAME + CAL namefile + + + + INSERT_CAL_KEY + CAL key + + + + CLEF_CD + Enter the CD-key + + + + BUFFER_POOL_SIZE + Buffer pool size + + + + ADDITIONAL_MEM_POOL_SIZE + Additionnal memory pool size + + + + LOG_FILE_SIZE + Log file size + + + + LOG_BUFFER_SIZE + Log file size + + + + NO_MODIFICATION_ASKED + No modification have been asked. + + + + NOT_NUM + Some characteres are not numeric characters. + + + + GREETING + Contrib developped by Marcadieu Lucas and Kelkermans Marc.]]> + + + \ No newline at end of file diff -urN smeserver-zarafa-0.9.0.orig/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/zarafaUI smeserver-zarafa-0.9.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/zarafaUI --- smeserver-zarafa-0.9.0.orig/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/zarafaUI 1970-01-01 10:00:00.000000000 +1000 +++ smeserver-zarafa-0.9.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/zarafaUI 2009-06-01 21:15:33.000000000 +1000 @@ -0,0 +1,273 @@ + + + + USER_GROUP_MANAGEMENT + Management + + + + FORM_TITLE + ]]> + + + + ADD_USER + Add an user + + + + ADD_USER_BUBBLE + Click here to add an user + + + + ADD_GROUP + Add a group + + + + ADD_GROUP_BUBBLE + Click here to add a group + + + + USERNAME + Username : + + + + FULLNAME + Fullname : + + + + DELETE + Delete + + + + DETAILS + User's details : + + + + STOCK_USE + Current store size : + + + + ACTIVE_USER + Active user : + + + + ACTIVE_CREATE + User : + + + + EMAILADDRESS + Email Address : + + + + ADMIN + Is the user an admin ? + + + + AUTO_ACCEPT_MEETING + Accept auto meeting request ? + + + + DECLINE_DLB_REQ + Decline dlb meeting request ? + + + + DECLINE_RECUR_REQ + Decline reccur meeting request ? + + + + QUOTA_OVERR + Set quota override ? + + + + WARN_LVL + Warning level (unit is Mo) : + + + + SOFT_LVL + Soft level (unit is Mo) : + + + + HARD_LVL + Hard level (unit is Mo) : + + + + PASSWORD + Password : + + + + CHANGE_PSSWD + New password (optional) : + + + + MODIFY_BUTTON + Modify + + + + CREATE_BUTTON + Create + + + + DELETE_BUTTON + Delete + + + + MODIFY_USER_SUCCESS + User's modified + + + + CREATE_USER_SUCCESS + User's created + + + + DELETE_USER_SUCCESS + User's deleted + + + + CREATE_GROUP_SUCCESS + Group's created + + + + DELETE_USER_TXT + Do you really want to delete this user ? + + + + GROUP_NAME + Group name : + + + + DELETE_GROUP_TXT + Do you really want to delete this group ? + + + + GROUP_TEXT_DISPLAY + Groups list + + + + CHECKED_YES + Yes + + + + CHECKED_NO + No + + + + GROUP_NAME_ARRAY + Group name + + + + DELETE_GROUP_SUCCESS + Group deleted + + + + MODIFY_GROUP_TEXT + Group's users modification + + + + MODIFY_GROUP_SUCCESS + Group modified + + + + EXIST_GROUP + Existing group : + + + + FULLNAME_VERIF_ERROR + The fullname is not a correct fullname. It may contain only alphabetical letters and/or interval. + + + + MY_PASSWORD_VERIF_ERROR + The password is not a correct password. It may contain only alphanumeric characters and at least six characters. + + + + QUOTA_TEST_VERIF_ERROR + The quota limit is not a correct quota. A correct quota limit is an numeric value. + + + + SOFT_INF_WARN + This quota limit can't be inferior or equal to the warning level quota. + + + + HARD_INF_OTHER + This quota limit can't be inferior or equal to the soft level quota. + + + + MULTIPLE_USERNAME + This username is already taken by another user, please choose another. + + + + MULTIPLE_EMAIL + This email address is already taken by another user, please choose another. + + + + MULTIPLE_GROUPNAME + This group name is already taken, please choose another. + + + + FALSE_USERNAME + The username is not a correct fullname. It may contain only alphabetical letters, intervals, points or coma. + + + + DISABLED + Disabled + + + + ENABLED + Enabled + + + + GREETING + Contrib developped by Marcadieu Lucas and Kelkermans Marc.]]> + + + \ No newline at end of file diff -urN smeserver-zarafa-0.9.0.orig/root/etc/e-smith/locale/fr/etc/e-smith/web/functions/zarafaCFG smeserver-zarafa-0.9.0/root/etc/e-smith/locale/fr/etc/e-smith/web/functions/zarafaCFG --- smeserver-zarafa-0.9.0.orig/root/etc/e-smith/locale/fr/etc/e-smith/web/functions/zarafaCFG 1970-01-01 10:00:00.000000000 +1000 +++ smeserver-zarafa-0.9.0/root/etc/e-smith/locale/fr/etc/e-smith/web/functions/zarafaCFG 2009-06-01 21:15:33.000000000 +1000 @@ -0,0 +1,238 @@ + + + + ZARAFA_CFG_MANAGEMENT + Serveur + + + + FORM_TITLE + + + + + SOFTDELETE + Réglage du soft-delete lifetime + + + + CFG_BUTTON + Configuration serveur + + + + KEY_BUTTON + Activation/Ajout de CAL + + + + MYSQL_BUTTON + Réglages MySQL + + + + CACHE_CELL_SIZE + Réglage de la taille du cache du noyau + + + + CACHE_OBJECT_SIZE + Réglage de la taille du cache objet + + + + CACHE_INDEX_SIZE + Réglage de la taille du cache l'index + + + + QUOTA_WARN + Réglage du niveau du Warning Quota + + + + QUOTA_SOFT + Réglage du niveau du Soft Quota + + + + QUOTA_HARD + Réglage du niveau du Hard Quota + + + + COMPANYQUOTA_WARN + Réglage du niveau de quota de companies + + + + VERSION + Version de Zarafa :]]> + + + + SYS_AUTH + Système de base de données : + + + + REGISTERED + Version enregistrée + + + + UNREGISTERED + Version communautaire + + + + MAX_USERS +
]]>
+
+ + + MODIFY_BUTTON + Modifier + + + + CD_KEY + Serial : + + + + NBRUSERTXT + utilisateurs maximum. + + + + CALNAME + Nom du fichier CAL + + + + CALKEY + Serial enregistré + + + + CAL_BUTTON + Ajouter un CAL + + + + MODIFY_CONFIG_SUCCESS + Modifications réussies ! + + + + CFG_BUTTON_BUBBLE + Cliquez ici pour configurer certain aspect de Zarafa + + + + KEY_BUTTON_BUBBLE + Cliquez ici pour activer votre version de Zarafa ou pour rajouter des CAL + + + + MYSQL_BUTTON_BUBBLE + Cliquez ici pour configurer certain aspect MySQL de Zarafa + + + + CAL_BUTTON_BUBBLE + Cliquez ici pour ajouter un CAL + + + + INVALID_KEY + Serial invalide. Il doit être obligatoirement composée de 24 caractéres alphanumériques. + + + + CREATE_BUTTON + Ajouter Serial + + + + EXIST_CALNAME + Le nom saisi est déjà  utilisé pour un autre CAL. Veuillez en choisir un autre. + + + + EXIST_CALKEY + Le serial saisi est déjà à utilisé dans un autre CAL. Veuillez en saisir un autre. + + + + CAUTION_TIME + ATTENTION - Les services Zarafa et MySQL doivent être redémarré.]]> + + + + INSERT_CAL_NAME + Nom du fichier CAL + + + + INSERT_CAL_KEY + Serial du CAL + + + + CLEF_CD + Saisir le serial + + + + BUFFER_POOL_SIZE + Taille du buffer pool + + + + ADDITIONAL_MEM_POOL_SIZE + Taille de la mémoire additionel du pool + + + + LOG_FILE_SIZE + Taille du fichier de log + + + + LOG_BUFFER_SIZE + Taille du fichier log du buffer + + + + NO_MODIFICATION_ASKED + Aucune modification n'a été demandé. + + + + NOT_NUM + Les caractéres saisi ne sont pas tous des caractéres numériques. + + + + MULTICOMP + Multi-companie + + + + GLOBALFORWARD + Gobal Forward + + + + ZARAFA_PLUGIN_CAUTION + Impossible de déterminer votre plugin + + + + GREETING + Contrib developped by Marcadieu Lucas and Kelkermans Marc.]]> + + +
\ No newline at end of file diff -urN smeserver-zarafa-0.9.0.orig/root/etc/e-smith/locale/fr/etc/e-smith/web/functions/zarafaUI smeserver-zarafa-0.9.0/root/etc/e-smith/locale/fr/etc/e-smith/web/functions/zarafaUI --- smeserver-zarafa-0.9.0.orig/root/etc/e-smith/locale/fr/etc/e-smith/web/functions/zarafaUI 1970-01-01 10:00:00.000000000 +1000 +++ smeserver-zarafa-0.9.0/root/etc/e-smith/locale/fr/etc/e-smith/web/functions/zarafaUI 2009-06-01 21:15:33.000000000 +1000 @@ -0,0 +1,284 @@ + + + + USER_GROUP_MANAGEMENT + Utilisateurs + + + + FORM_TITLE + ]]> + + + + ADD_USER + Ajouter un utilisateur + + + + ADD_USER_BUBBLE + Cliquez pour ajouter un utilisateur + + + + ADD_GROUP + Ajouter un groupe + + + + ADD_GROUP_BUBBLE + Cliquez pour ajouter un groupe + + + + USERNAME + Nom utilisateur : + + + + FULLNAME + Nom complet : + + + + DELETE + Supprimer + + + + DETAILS + Détails de l'utilisateur : ]]> + + + + STOCK_USE + Espace de stockage utilisé : + + + + ACTIVE_USER + Utilisateur actif : ]]> + + + + ACTIVE_CREATE + Utilisateur : + + + + EMAILADDRESS + Adresse internet : + + + + ADMIN + L'utilisateur est-il un administrateur ? + + + + AUTO_ACCEPT_MEETING + Accept auto meeting request ? + + + + DECLINE_DLB_REQ + Decline dlb meeting request ? + + + + DECLINE_RECUR_REQ + Decline reccur meeting request ? + + + + QUOTA_OVERR + Mettre des quotas personalisés ? + + + + WARN_LVL + Warning level (en Mo) : + + + + SOFT_LVL + Soft level (en Mo) : + + + + HARD_LVL + Hard level (en Mo) : + + + + PASSWORD + Mot de passe : + + + + CHANGE_PSSWD + Nouveau mot de passe (optionnel) : + + + + MODIFY_BUTTON + Modifier + + + + CREATE_BUTTON + Créer + + + + DELETE_BUTTON + Supprimer + + + + MODIFY_USER_SUCCESS + Utilisateur modifié + + + + CREATE_USER_SUCCESS + Utilisateur créé + + + + DELETE_USER_SUCCESS + Utilisateur supprimé + + + + CREATE_GROUP_SUCCESS + Groupe créé + + + + DELETE_USER_TXT + Voulez vous vraiment supprimer cet utilisateur ? + + + + GROUP_NAME + Nom du groupe : + + + + DELETE_GROUP_TXT + Voulez-vous vraiment supprimer ce groupe ? + + + + GROUP_TEXT_DISPLAY + Liste des groupes + + + + CHECKED_YES + Oui + + + + CHECKED_NO + Non + + + + GROUP_NAME_ARRAY + Nom du groupe + + + + DELETE_GROUP_SUCCESS + Groupe supprimé + + + + MODIFY_GROUP_TEXT + Modification des utilisateurs du groupe]]> + + + + MODIFY_GROUP_SUCCESS + Groupe modifié + + + + EXIST_GROUP + Groupes existant : + + + + FULLNAME_VERIF_ERROR + Le nom d'utilisateur rentré n'est pas un nom valide. Il ne doit contenir que des lettres de l'alphabet, des espace, des points ou bien des tirets. + + + + MY_PASSWORD_VERIF_ERROR + Le mot de passe saisi n'est pas considéré comme valide. Le mot de passe ne doit contenir que des caractéres alphanumérique et doit contenir au moins 6 caractéres. + + + + QUOTA_TEST_VERIF_ERROR + La limite de quota saisi n'est pas valide. Une limite valide est une valeur numérique. + + + + SOFT_INF_WARN + La limite de se quota ne peut être inférieur ou égale à la limite du warning level. + + + + HARD_INF_OTHER + La limite de se quota ne peut être inférieur ou égale à la limite du soft level. + + + + MULTIPLE_USERNAME + Le nom d'utilisateur saisi est déja utilisé, veuillez en choisir un autre. + + + + MULTIPLE_EMAIL + L'email saisi est déjà utilisé par un autre utilisateur, veuillez en saisir un autre. + + + + MULTIPLE_GROUPNAME + Ce nom de groupe est djà utilisé, veuillez en saisir un autre. + + + + FALSE_USERNAME + Ce nom d'utilisateur n'est pas validable. Il ne doit contenir que des caractéres alphanumérique, des points ou encore des tirets + + + + ENABLED + Activé + + + + DISABLED + Désactivé + + + + GREETING + Contrib developped by Marcadieu Lucas and Kelkermans Marc.]]> + + + + CAUTION_NOT_DB +

]]>
+
+ + + + IN_DB +

]]>
+
+ +
\ No newline at end of file diff -urN smeserver-zarafa-0.9.0.orig/root/etc/e-smith/web/functions/zarafaCFG smeserver-zarafa-0.9.0/root/etc/e-smith/web/functions/zarafaCFG --- smeserver-zarafa-0.9.0.orig/root/etc/e-smith/web/functions/zarafaCFG 1970-01-01 10:00:00.000000000 +1000 +++ smeserver-zarafa-0.9.0/root/etc/e-smith/web/functions/zarafaCFG 2009-06-01 21:15:42.000000000 +1000 @@ -0,0 +1,127 @@ +#!/usr/bin/perl -wT + +# vim: ts=4 sw=4 et: +#---------------------------------------------------------------------- +# heading : Zarafa +# description : ZARAFA_CFG_MANAGEMENT +# navigation : 2000 2200 +#---------------------------------------------------------------------- + + use strict; + use warnings; + use esmith::FormMagick::Panel::zarafaCFG; + + my $f = esmith::FormMagick::Panel::zarafaCFG->new(); + $f->display(); + +__DATA__ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CAUTION_TIME + + + + + + + + + + + + + + + + + + CAUTION_TIME + + + + + + + + + + + + + + + + + + + + + + + + + + CAUTION_TIME + + + + + + + + + + + + +
\ No newline at end of file diff -urN smeserver-zarafa-0.9.0.orig/root/etc/e-smith/web/functions/zarafaUI smeserver-zarafa-0.9.0/root/etc/e-smith/web/functions/zarafaUI --- smeserver-zarafa-0.9.0.orig/root/etc/e-smith/web/functions/zarafaUI 1970-01-01 10:00:00.000000000 +1000 +++ smeserver-zarafa-0.9.0/root/etc/e-smith/web/functions/zarafaUI 2009-06-01 21:15:42.000000000 +1000 @@ -0,0 +1,193 @@ +#!/usr/bin/perl -wT + +# vim: ts=4 sw=4 et: +#---------------------------------------------------------------------- +# heading : Zarafa +# description : USER_GROUP_MANAGEMENT +# navigation : 2000 2150 +#---------------------------------------------------------------------- + + use strict; + use warnings; + use esmith::FormMagick::Panel::zarafaUI; + + my $f = esmith::FormMagick::Panel::zarafaUI->new(); + $f->display(); + + __DATA__ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DELETE_USER_TXT + + + + + + + + + + + + + + + + DELETE_GROUP_TXT + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DELETE_COMPANY_TXT + + + + + +
\ No newline at end of file diff -urN smeserver-zarafa-0.9.0.orig/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/zarafaCFG.pm smeserver-zarafa-0.9.0/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/zarafaCFG.pm --- smeserver-zarafa-0.9.0.orig/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/zarafaCFG.pm 1970-01-01 10:00:00.000000000 +1000 +++ smeserver-zarafa-0.9.0/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/zarafaCFG.pm 2009-06-01 21:15:18.000000000 +1000 @@ -0,0 +1,964 @@ +#!/usr/bin/perl -w + +package esmith::FormMagick::Panel::zarafaCFG; + + use strict; + use warnings; + use esmith::FormMagick; + use esmith::cgi; + use esmith::util; + use Exporter; + use esmith::ConfigDB; + use utf8; + + our @ISA = qw(esmith::FormMagick Exporter); + + our @EXPORT = qw(); + + our $VERSION = sprintf '%d.%03d', q$Revision: 1.1 $ =~ /: (\d+).(\d+)/; + + our $configdb = esmith::ConfigDB->open(); + + # Longueur des clef de license pour vérification + our $licensekey = 24; + our $CALkey = 16; + +# Ce fichier contient les fonction nécessaire pour gérer l'interface entre le serveur SME et la configuration de certain paramétres du module Zarafa. +# Ce fichier regroupe des fonctions d'affichage, de modifications et de vérifications de données contenu dans Zarafa. +##################################################################################################################################### +# This file contains the required functions in order to handle the interface between SME server and Zarafa configuration module's. +# It contains display, modify, create and verification functions for Zarafa. + + +# display_config permet l'affichage d'options et le préremplissage de champs pour la configuration du serveur de messagerie +########################################################################################################################### +# display_config is used to display options and to fill many fields for the mail's server + +sub display_config { + + my $self = shift; + my $cgi = $self->{cgi}; + + # Récupération des valeurs à inséré dans les champs + # Recovery of value to put into fields + my ($softdelete, $cache_cell, $cache_object, $cache_index, $quota_warn, $quota_soft, $quota_hard, $companyquota_warn, $multicompany); + open(LIRE, "/etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg"); + while(){ + my $ligne = $_; + if($ligne =~ m/^softdelete_lifetime/){ + $softdelete = $ligne; + $softdelete =~ s/softdelete_lifetime\s+\=\s{1}//g; + } + if($ligne =~ m/^cache_cell_size/){ + $cache_cell = $ligne; + $cache_cell =~ s/cache_cell_size\s+\=\s{1}//g; + } + if($ligne =~ m/^cache_object_size/){ + $cache_object = $ligne; + $cache_object =~ s/cache_object_size\s+\=\s{1}//g; + } + if($ligne =~ m/^cache_indexedobject_size/){ + $cache_index = $ligne; + $cache_index =~ s/cache_indexedobject_size\s+\=\s{1}//g; + } + if($ligne =~ m/^quota_warn/){ + $quota_warn = $ligne; + $quota_warn =~ s/quota_warn\s+\=\s{1}//g; + } + if($ligne =~ m/^quota_soft/){ + $quota_soft = $ligne; + $quota_soft =~ s/quota_soft\s+\=\s{1}//g; + } + if($ligne =~ m/^quota_hard/){ + $quota_hard = $ligne; + $quota_hard =~ s/quota_hard\s+\=\s{1}//g; + } + if($ligne =~ m/^companyquota_warn/){ + $companyquota_warn = $ligne; + $companyquota_warn =~ s/companyquota_warn\s+\=\s{1}//g; + } + if($ligne =~ m/^enable_hosted_zarafa/){ + $multicompany = $ligne; + $multicompany =~ s/enable_hosted_zarafa\s+\=\s//g; + } + } + close(LIRE); + + # Affichage des valeurs récupérées + # Display of the precedent values + $cgi->param(-name=>'Softdelete', -value=>$softdelete); + $cgi->param(-name=>'cache_cell', -value=>$cache_cell); + $cgi->param(-name=>'cache_object', -value=>$cache_object); + $cgi->param(-name=>'cache_index', -value=>$cache_index); + $cgi->param(-name=>'quota_warn', -value=>$quota_warn); + $cgi->param(-name=>'quota_soft', -value=>$quota_soft); + $cgi->param(-name=>'quota_hard', -value=>$quota_hard); + $cgi->param(-name=>'companyquota_warn', -value=>$companyquota_warn); + + # Localisation + my $multicomp = $self->localise('MULTICOMP'); + my $globalforward = $self->localise('GLOBALFORWARD'); + my $enabled = $self->localise('ENABLED'); + + + my $out = "\n " + . "$multicomp" + . "\n \n" + . " \n"; + if($multicompany =~ m/true/){ + $out .="" + ."\n"; + } + else { + $out .="" + ."\n"; + } + $out .= "
$enabled
$enabled
\n \n \n"; + + $out .= "\n " + . "$globalforward" + . "\n \n" + . " \n"; + unless(!$configdb->get_prop("zarafa-server",'GlobalForward')){ + if($configdb->get_prop("zarafa-server",'GlobalForward') =~ m/enabled/){ + $out .="" + ."\n"; + } + } + else { + $out .="" + ."\n"; + } + $out .= "
$enabled
$enabled
\n \n \n"; + +return $out; +} + +# display_modify_button affiche un bouton avec le texte "Modifier" +########################################################### +# display_modify_button display a button with "Modify" text on it + +sub display_modify_button { + + my ($self) = @_; + my $cgi = $self->{cgi}; + my $button = $self->localise('MODIFY_BUTTON'); + $self->print_button("$button"); +} + +# modify_config récupére les valeurs saisi dans l'interface pour les entrés dans le serveur +########################################################################################### +# modify_config recover the values enter in the interface to put them into the server configuration + +sub modify_config { + + my $self = shift; + my $cgi = $self->{cgi}; + + # Récupération des valeurs + # Revover of the value + my $softdelete = $cgi->param('Softdelete'); + if ($softdelete =~ /^([-\@\w.]+)$/) { + $softdelete = $1; # $data now untainted + } + else { + die "bad data in $softdelete"; + } + + my $cache_cell = $cgi->param('cache_cell'); + if ($cache_cell =~ /^([-\@\w.]+)$/) { + $cache_cell = $1; # $data now untainted + } + else { + die "bad data in $cache_cell"; + } + + my $cache_object = $cgi->param('cache_object'); + if ($cache_object =~ /^([-\@\w.]+)$/) { + $cache_object = $1; # $data now untainted + } + else { + die "bad data in $cache_object"; + } + + my $cache_index = $cgi->param('cache_index'); + if ($cache_index =~ /^([-\@\w.]+)$/) { + $cache_index = $1; # $data now untainted + } + else { + die "bad data in $cache_index"; + } + + my $quota_warn = $cgi->param('quota_warn'); + if ($quota_warn =~ /^([-\@\w.]+)$/) { + $quota_warn = $1; # $data now untainted + } + else { + die "bad data in $quota_warn"; + } + + my $quota_soft = $cgi->param('quota_soft'); + if ($quota_soft =~ /^([-\@\w.]+)$/) { + $quota_soft = $1; # $data now untainted + } + else { + die "bad data in $quota_soft"; + } + + my $quota_hard = $cgi->param('quota_hard'); + if ($quota_hard =~ /^([-\@\w.]+)$/) { + $quota_hard = $1; # $data now untainted + } + else { + die "bad data in $quota_hard"; + } + + my $companyquota_warn = $cgi->param('companyquota_warn'); + if ($companyquota_warn =~ /^([-\@\w.]+)$/) { + $companyquota_warn = $1; # $data now untainted + } + else { + die "bad data in $companyquota_warn"; + } + + my $multicompany = $cgi->param('multicompany'); + + + # Récupération du contenu de server.cfg + # Recovery of the content of server.cfg + open(RECUP, "/etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg"); + my @contenu = ; + close(RECUP); + + # Remplacement des valeurs + # Replacement of values + foreach my $ligne (@contenu){ + unless ($ligne =~ m/^#/){ + if ($ligne =~ m/^softdelete_lifetime/){ + $ligne =~ s/\w+$/$softdelete/g; + } + + if($ligne =~ m/^cache_cell_size/){ + $ligne =~ s/\w+$/$cache_cell/g; + } + + if($ligne =~ m/^cache_object_size/){ + $ligne =~ s/\w+$/$cache_object/g; + } + + if($ligne =~ m/^cache_indexedobject_size/){ + $ligne =~ s/\w+$/$cache_index/g; + } + if($ligne =~ m/^quota_warn/){ + $ligne =~ s/\w+$/$quota_warn/g; + } + if($ligne =~ m/^quota_soft/){ + $ligne =~ s/\w+$/$quota_soft/g; + } + if($ligne =~ m/^quota_hard/){ + $ligne =~ s/\w+$/$quota_hard/g; + } + if($ligne =~ m/^companyquota_warn/){ + $ligne =~ s/\w+$/$companyquota_warn/g; + } + if($ligne =~ m/^enable_hosted_zarafa/ && !$multicompany){ + $ligne =~ s/\w+$/false/g; + } + elsif($ligne =~ m/^enable_hosted_zarafa/ && $multicompany eq 'enabled'){ + $ligne =~ s/\w+$/true/g; + } + } + } + + # Ecriture du fichier + # File written + open(ECRIRE, ">/etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg"); + foreach my $ligne (@contenu) { + chomp $ligne; + print ECRIRE "$ligne\n"; + } + close(ECRIRE); + + my $globalforward = $cgi->param('globalforward'); + + + if(!$globalforward || $globalforward =~ m/disabled/) { + system("/sbin/e-smith/db configuration delprop \"zarafa-server\" GlobalForward"); + } + elsif($globalforward =~ m/enabled/){ + system("/sbin/e-smith/db configuration setprop \"zarafa-server\" GlobalForward enabled"); + } + + + + $self->success('MODIFY_CONFIG_SUCCESS'); + + # creation du fichier de configuration + # config file creation + system("/sbin/e-smith/expand-template /etc/zarafa/server.cfg") == 0 + or die "Impossible d'extend le template"; + system("/etc/e-smith/events/actions/zarafa-services stop > /dev/null"); + system("/etc/e-smith/events/actions/zarafa-services start > /dev/null"); + system("/etc/e-smith/events/actions/qmail-update-user"); +} + +# display_buttons permet d'afficher les trois bouttons pour les différentes sections de configuration +##################################################################################################### +# display_buttons allow you to display three buttons for the different parts of the configuration + +sub display_buttons { + + my $self = shift; + my $q = $self->{cgi}; + + # Récupération version de zarafa + # Recovery of Zarafa version + my $product_version; + open(VERS,"zarafa-admin -V |"); + while(){ + my $ligne = $_; + if($ligne =~ m/^Product version/){ + $ligne =~ s/\w+\s\w+:\t//g; + $product_version = $ligne; + } + } + close(VERS); + + # Récupération du systéme de BD + # Recovery of DB system + my $zarafa_plugin = $configdb->get_prop("zarafa-server",'Plugin'); + unless($zarafa_plugin){ + $zarafa_plugin = $self->localise('ZARAFA_PLUGIN_CAUTION'); + } + + # Version communautaire ou enregistré ? + # Registered or enregistered version ? + my $registered; + if(-e "/etc/zarafa/license/base"){ + $registered = $self->localise('REGISTERED'); + } + else { + $registered = $self->localise('UNREGISTERED'); + } + + # Récupération du nombre d'utilisateur maximum + # Recovery of maximum users + my $nbrusermax; + open(REVERSE, "/var/log/zarafa/licensed.log") or die "Impossible d'ouvrir licensed.log"; + foreach my $ligne (reverse( )) { + if($ligne =~ m/License is for/){ + $nbrusermax = $ligne; + $nbrusermax =~ s/.+License is for //g; + $nbrusermax =~ s/ Win32 MAPI users$//g; + $nbrusermax =~ s/ total users$//g; + last; + } + } + close(REVERSE); + + # Localisation + my $version = $self->localise('VERSION'); + my $sys_auth = $self->localise('SYS_AUTH'); + my $maxuser = $self->localise('MAX_USERS'); + + + # Affichage des info + # Information display + print "$version $product_version - $sys_auth $zarafa_plugin - $registered - $nbrusermax $maxuser \n"; + + # Localisation + my $CFGbutton = $self->localise('CFG_BUTTON'); + my $CFGbutton_bubble = $self->localise('CFG_BUTTON_BUBBLE'); + + # Affichage bouton configuration + # Display the configuration button + my $out ="

$CFGbutton"; + + # Localisation + my $KEYbutton = $self->localise('KEY_BUTTON'); + my $KEYbutton_bubble = $self->localise('KEY_BUTTON_BUBBLE'); + + if(-e "/etc/zarafa/license/base"){ + # Affichage bouton de gestion des clef pour une version enregistrée + # Display the key management button for a registered version + $out .="$KEYbutton"; + } + else{ + # Affichage bouton de validation de la version + # Display the version validation button + $out .="$KEYbutton"; + } + + # Localisation + my $MYSQLbutton = $self->localise('MYSQL_BUTTON'); + my $MYSQLbutton_bubble = $self->localise('MYSQL_BUTTON_BUBBLE'); + + # Affichage bouton MySQL + # Display the MySQL button + $out .="$MYSQLbutton

"; + + return $out; +} + +# add_cdkey est utilisé pour ajouter une clé-CD pour authentifier Zarafa +####################################################################### +# add_cdkey is used to add a CD-key to authenticate Zarafa + +sub add_cdkey{ + + my $self = shift; + my $cgi = $self->{cgi}; + + # Récupération de la clef saisi par l'utilisateur + # Recovery of the key enter by the user + my $cd_key = $cgi->param('clef-cd'); + if ($cd_key =~ /^([-\@\w.]+)$/) { + $cd_key = $1; # $data now untainted + } + else { + die "bad data in $cd_key"; + } + + # Ecriture du fichier base + # Writing of the base file + $cd_key = uc($cd_key); + open(ECRIRE, ">/etc/zarafa/license/base"); + print ECRIRE "$cd_key"; + close(ECRIRE); + + $self->success('ADD_LICENSE_SUCCESS'); + + # Redémarage des services zarafa + # Restart of Zarafa services + system("/etc/e-smith/events/actions/zarafa-services restart > /dev/null"); +} + +# display_key_info permet d'afficher la clef-cd de la version en cours de zarafa ainsi que le nombre maximum d'utilisateurs pouvant être créé. +############################################################################################################################################## +# display_key_info is used to display the CD-key of zarafa current version and the maximum number of Zarafa user's could be created. + +sub display_key_info { + + my $self = shift; + my $cgi = $self->{cgi}; + + # Récupération de la clé-CD + # Recovery of the CD-key + open(KEYS,"/etc/zarafa/license/base"); + my $key = ; + close(KEYS); + # Localisation + my $clef = $self->localise('CD_KEY'); + my $nbrusertxt = $self->localise('NBRUSERTXT'); + + # Récupération du nombre maximum d'utilisateurs + # Recovery of the maximum users number + my $nbrusermax; + open(REVERSE, "/var/log/zarafa/licensed.log") or die "Impossible d'ouvrir licensed.log"; + foreach my $ligne (reverse( )) { + if($ligne =~ m/License is for/){ + $nbrusermax = $ligne; + $nbrusermax =~ s/.+License is for //g; + $nbrusermax =~ s/ Win32 MAPI users$//g; + $nbrusermax =~ s/ total users$//g; + last; + } + } + close(REVERSE); + + # Affichage + # Display + print "$clef $key - $nbrusermax $nbrusertxt"; + return 0; +} + +# valid_keys est utilisé pour vérifier si la clef-CD rentré pour renregistré zarafa est valide +############################################################################################## +# valid_keys is used to verify if the CD-key enter for registered Zarafa is correct + +sub valid_keys { + + my ($fm, $cd_key) = @_; + my $self = shift; + my $return_error = $self->localise('INVALID_KEY'); + + if($cd_key =~ m/^\w{$licensekey}$/){ + return "OK"; + } + else { + return $return_error; + } +} + +# display_cal sert à afficher un tableau contenant le nom des CAL ainsi que la clef associée +############################################################################################ +# display_cal is used to display an array which contain all CAl and the key associated + +sub display_cal { + + my $self = shift; + my $q = $self->{cgi}; + + # Localisation + my $calname = $self->localise('CALNAME'); + my $calkey = $self->localise('CALKEY'); + my $caldelete = $self->localise('DELETE'); + + # Affichage de l'en-tête du tableau + # Display of the header + print " \n \n "; + print $q->start_table ({-CLASS => "sme-border"}),"\n "; + print $q->Tr( + esmith::cgi::genSmallCell($q, $calname,"header"), + esmith::cgi::genSmallCell($q, $calkey,"header")); + + + # Récupération du nom des fichiers CAL + # Recovery of the CAL file name + my $filekey; + opendir(OPENDIR, "/etc/zarafa/license") or die "Impossible d'ouvrir /etc/zarafa/license"; + my @all_files = readdir (OPENDIR); + close(OPENDIR); + + # Affichage du nom et de la clef + # Display of the name and the key + my @out = sort @all_files; + foreach my $file (@out) { + unless($file eq 'base' or $file eq '..' or $file eq '.'){ + open(FILE, "/etc/zarafa/license/$file") or die "Impossible d'ouvrir $file"; + $filekey = ; + print $q->Tr( + esmith::cgi::genSmallCell($q, $file,"normal"), + esmith::cgi::genSmallCell($q, $filekey,"normal")); + close(FILE); + } + } + + print qq(\n); + + # Localisation + my $createCal = $self->localise('CAL_BUTTON'); + my $createCal_bubble = $self->localise('CAL_BUTTON_BUBBLE'); + + # Affichage bouton ajouter CAL + # Display the CAL's create button + my $out ="

$createCal"; + +return $out; +} + +# display_create_button permet d'afficher un bouton avec le texte "Ajouter Clé" +############################################################################### +# display_create_button is used to display a button with "Add key" text + +sub display_create_button { + + my ($self) = @_; + my $cgi = $self->{cgi}; + + my $button = $self->localise('CREATE_BUTTON'); + $self->print_button("$button"); +} + +# create_cal permet de rajouter un CAL à zarafa +############################################### +# create_cal is used to add a CAL to zarafa + +sub create_cal { + + my $self = shift; + my $cgi = $self->{cgi}; + + # Récupération du nom du CAL et de la clef + # Recovery of the CAL name and the key + my $calname = $cgi->param('user_name_cal'); + if ($calname =~ /^([-\@\w.]+)$/) { + $calname = $1; # $data now untainted + } + else { + die "bad data in $calname"; + } + + my $calkey = $cgi->param('user_key_cal'); + if ($calkey =~ /^([-\@\w.]+)$/) { + $calkey = $1; # $data now untainted + } + else { + die "bad data in $calkey"; + } + + # Ecriture du fichier + # Writing of the file + open(CREATE, ">/etc/zarafa/license/$calname"); + print CREATE $calkey; + close(CREATE); + + $self->success('MODIFY_CONFIG_SUCCESS'); + + # Redémarrage des services Zarafa + # Restart of the zarafa services + system("/etc/e-smith/events/actions/zarafa-services restart > /dev/null"); +} + +# unique_cal sert a vérifier si le nom du CAL est déjà pris +########################################################### +# unique_cal is used to verify if the CAL name is already taken + +sub unique_name { + + my ($fm, $calname) = @_; + my $self = shift; + my $return_error = $self->localise('EXIST_CALNAME'); + + # Récupération des noms des CAL existant + # Recovery of all existing CAL names + opendir(OPENDIR, "/etc/zarafa/license") or die "Impossible d'ouvrir /etc/zarafa/license"; + my @all_files = readdir (OPENDIR); + close(OPENDIR); + + # On vérifie si le nom est déja pris + # CAL name have been already taken ? + my $exist = 0; + foreach my $file (@all_files){ + if($file eq $calname){ + $exist = 1; + } + } + if($exist == 1){ + return $return_error; + } + else { + return "OK"; + } +} + +# unique_key sert a vérifier si la clef du CAL est déjà prise +############################################################# +# unique_key is used to verify if the CAL key is already taken + +sub unique_key { + + + my ($fm, $calkey) = @_; + my $self = shift; + my $return_error = $self->localise('EXIST_CALKEY'); + + my $exist = 0; + my $filekey; + + # Récupération des noms des CAL existant + # Recovery of all existing CAL names + opendir(OPENDIR, "/etc/zarafa/license") or die "Impossible d'ouvrir /etc/zarafa/license"; + my @all_files = readdir (OPENDIR); + close(OPENDIR); + + # Parcours de chaque fichier + # Read of all files + foreach my $file (@all_files) { + # Vérification + # Verification + open(FILE, "/etc/zarafa/license/$file") or die "Impossible d'ouvrir $file"; + $filekey = ; + if($filekey =~ m/$calkey/){ + $exist = 1; + } + close(FILE); + } + + if($exist == 1){ + return $return_error; + } + else { + return "OK"; + } +} + +# valid_cal est utilisé pour vérifier si la clef rentré est valide lors de la création d'un CAL +############################################################################################### +# valid_cal is used to verify if the key enter for create a CAL is correct + +sub valid_cal { + + my ($fm, $cd_key) = @_; + my $self = shift; + my $return_error = $self->localise('INVALID_KEY'); + + if($cd_key =~ m/^\w{$CALkey}$/){ + return "OK"; + } + else { + return $return_error; + } +} + +# display_value est utilisé pour affiché les valeurs de fichiers de configuration MySQL dans l'interface +######################################################################################################## +# display_value is used to display MySQL configuration values into the interface + +sub display_value { + + my $self = shift; + my $cgi = $self->{cgi}; + + # Affichage d'une checkbox pour la fonction InnoDB + # Display of a checkbox for the InnoDB function + my $enabled = $self->localise('ENABLED'); + my $out = "\n " + . "InnoDB" + . "\n \n" + . " \n"; + if($configdb->get_prop('mysqld','InnoDB')){ + $out .="" + ."\n"; + } + else { + $out .="" + ."\n"; + } + $out .= "
$enabled
$enabled
\n \n \n"; + + # Récupération et affichage des valeurs du fichier de configuration + # Recovery and display of the configuration file values + my $ligne; + open(MYCNF, "/etc/e-smith/templates/etc/my.cnf/009innodb") or die "Impossible d'ouvrir 0009innodb"; + while(){ + $ligne = $_; + if($ligne =~ m/buffer_pool_size/){ + $ligne =~ s/^\s+\$OUT\s\.\=\s\"\w+\s\=\s//g; + $ligne =~ s/M\\n\"\;$//g; + $cgi->param(-name=>'buffer_pool_size', -value=>$ligne); + } + elsif($ligne =~ m/additional_mem_pool_size/){ + $ligne =~ s/^\s+\$OUT\s\.\=\s\"\w+\s\=\s//g; + $ligne =~ s/M\\n\"\;$//g; + $cgi->param(-name=>'additional_mem_pool_size', -value=>$ligne); + } + elsif($ligne =~ m/log_file_size/){ + $ligne =~ s/^\s+\$OUT\s\.\=\s\"\w+\s\=\s//g; + $ligne =~ s/M\\n\"\;$//g; + $cgi->param(-name=>'log_file_size', -value=>$ligne); + } + elsif($ligne =~ m/log_buffer_size/){ + $ligne =~ s/^\s+\$OUT\s\.\=\s\"\w+\s\=\s//g; + $ligne =~ s/M\\n\"\;$//g; + $cgi->param(-name=>'log_buffer_size', -value=>$ligne); + } + } + close(MYCNF); + +return $out; +} + +# modify_mysql permet de modifier les valeurs du fichier de configuration MySQL +############################################################################### +# modify_mysql is used to modify the value of the MySQL configuration file + +sub modify_mysql { + + my $self = shift; + my $cgi = $self->{cgi}; + + # Récupération de la valeur courante et du réglage utilisateur de InnoDB + # Recovery of the current value and user value of InnoDB + my $innodb = $cgi->param('InnoDB'); + my $current_innodb = $configdb->get_prop('mysqld','InnoDB'); + + # Si l'utilisateur désactive le service InnoDB + # If the user disable the InnoDB service + if($current_innodb eq 'enabled' && !$innodb){ + # Arrêt des services MySQL et Zarafa + # Stop of MySQL and Zarafa services + system("/etc/e-smith/events/actions/zarafa-services stop > /dev/null"); + system("/sbin/service mysqld stop > /dev/null"); + # Suppression des fichiers MySQL + # Deleting MySQL file + system("rm -R -f /var/lib/mysql/ib_logfile0"); + system("rm -R -f /var/lib/mysql/ib_logfile1"); + system("rm -R -f /var/lib/mysql/ibdata1"); + + # Rechargement des paramêtres par défaut de MySQL + # Reload MySQL defaults adjustements + open(MYCNF, "/etc/e-smith/templates/etc/my.cnf/009innodb") or die "Impossible d'ouvrir 0009innodb"; + my @contenu = ; + close(MYCNF); + + foreach my $ligne (@contenu){ + if($ligne =~ m/buffer_pool_size/){ + $ligne =~ s/\d+/16/g; + } + elsif($ligne =~ m/additional_mem_pool_size/){ + $ligne =~ s/\d+/2/g; + } + elsif($ligne =~ m/log_file_size/){ + $ligne =~ s/\d+/5/g; + } + elsif($ligne =~ m/log_buffer_size/){ + $ligne =~ s/\d+/8/g; + } + } + open(ECRIRE, ">/etc/e-smith/templates/etc/my.cnf/009innodb"); + foreach my $ligne (@contenu) { + chomp $ligne; + print ECRIRE "$ligne\n"; + } + close(ECRIRE); + + # Suppression de l'InnoDB et redémarrage des services + # Delete of InnoDB and restart services + system("/sbin/e-smith/db configuration delprop mysqld InnoDB"); + system("/sbin/e-smith/expand-template /etc/my.cnf"); + system("/sbin/service mysqld start > /dev/null"); + system("/etc/e-smith/events/actions/zarafa-services start > /dev/null"); + + $self->success('MODIFY_CONFIG_SUCCESS'); + } + # Activation du service InnoDB + # Activation of InnoDB service + elsif(!$current_innodb && $innodb eq 'enabled'){ + # Ajout de l'InnoDB, arrêt des services MySQL et Zarafa et suppression des fichiers MySQL + # Add the InnoDB, stop MySQL and Zarafa service and delete MySQL file + system("/sbin/e-smith/db configuration setprop mysqld InnoDB enabled"); + system("/etc/e-smith/events/actions/zarafa-services stop > /dev/null"); + system("/sbin/service mysqld stop > /dev/null"); + system("rm -R -f /var/lib/mysql/ib_logfile0"); + system("rm -R -f /var/lib/mysql/ib_logfile1"); + system("rm -R -f /var/lib/mysql/ibdata1"); + + # Récupération du contenu du fichier configuration MySQL, modification des valeurs et écriture + # Recovery of the MysQL configuration file, values modification and writing + open(MYCNF, "/etc/e-smith/templates/etc/my.cnf/009innodb") or die "Impossible d'ouvrir 0009innodb"; + my @contenu = ; + close(MYCNF); + + my $buffer_pool_size = $cgi->param('buffer_pool_size'); + my $additional_mem_pool_size = $cgi->param('additional_mem_pool_size'); + my $log_file_size = $cgi->param('log_file_size'); + my $log_buffer_size = $cgi->param('log_buffer_size'); + + foreach my $ligne (@contenu){ + if($ligne =~ m/buffer_pool_size/){ + $ligne =~ s/\d+/$buffer_pool_size/g; + } + elsif($ligne =~ m/additional_mem_pool_size/){ + $ligne =~ s/\d+/$additional_mem_pool_size/g; + } + elsif($ligne =~ m/log_file_size/){ + $ligne =~ s/\d+/$log_file_size/g; + } + elsif($ligne =~ m/log_buffer_size/){ + $ligne =~ s/\d+/$log_buffer_size/g; + } + } + + open(ECRIRE, ">/etc/e-smith/templates/etc/my.cnf/009innodb"); + foreach my $ligne (@contenu) { + chomp $ligne; + print ECRIRE "$ligne\n"; + } + close(ECRIRE); + + # Génération du fichier configuration et redémarrage des services + # Configuration file generation and restart services + system("/sbin/e-smith/expand-template /etc/my.cnf"); + system("/sbin/service mysqld start > /dev/null"); + system("/etc/e-smith/events/actions/zarafa-services start > /dev/null"); + + $self->success('MODIFY_CONFIG_SUCCESS'); + } + # Simple modifications des valeurs + # Only values modifications + elsif($current_innodb eq 'enabled' && $innodb eq 'enabled'){ + # Arrêt des services MySQL et Zarafa + # Stop of MySQL and Zarafa services + system("/etc/e-smith/events/actions/zarafa-services stop > /dev/null"); + system("/sbin/service mysqld stop > /dev/null"); + # Suppression des fichiers MySQL + # Deleting MySQL file + system("rm -R -f /var/lib/mysql/ib_logfile0"); + system("rm -R -f /var/lib/mysql/ib_logfile1"); + system("rm -R -f /var/lib/mysql/ibdata1"); + + + # Récupération du contenu du fichier configuration MySQL, modification des valeurs et écriture + # Recovery of the MysQL configuration file, values modification and writing + open(MYCNF, "/etc/e-smith/templates/etc/my.cnf/009innodb") or die "Impossible d'ouvrir 0009innodb"; + my @contenu = ; + close(MYCNF); + + my $buffer_pool_size = $cgi->param('buffer_pool_size'); + my $additional_mem_pool_size = $cgi->param('additional_mem_pool_size'); + my $log_file_size = $cgi->param('log_file_size'); + my $log_buffer_size = $cgi->param('log_buffer_size'); + + foreach my $ligne (@contenu){ + if($ligne =~ m/buffer_pool_size/){ + $ligne =~ s/\d+/$buffer_pool_size/g; + } + elsif($ligne =~ m/additional_mem_pool_size/){ + $ligne =~ s/\d+/$additional_mem_pool_size/g; + } + elsif($ligne =~ m/log_file_size/){ + $ligne =~ s/\d+/$log_file_size/g; + } + elsif($ligne =~ m/log_buffer_size/){ + $ligne =~ s/\d+/$log_buffer_size/g; + } + } + + open(ECRIRE, ">/etc/e-smith/templates/etc/my.cnf/009innodb"); + foreach my $ligne (@contenu) { + chomp $ligne; + print ECRIRE "$ligne\n"; + } + close(ECRIRE); + + # Génération du fichier configuration et redémarrage des services + # Configuration file generation and restart services + system("/sbin/e-smith/expand-template /etc/my.cnf"); + system("/sbin/service mysqld start > /dev/null"); + system("/etc/e-smith/events/actions/zarafa-services start > /dev/null"); + + $self->success('MODIFY_CONFIG_SUCCESS'); + } + else { + $self->success('NO_MODIFICATION_ASKED'); + } +} + +# only_num permet de vérifier si une valeur ne contient bien que des chiffres +############################################################################# +# only_num is used to verify if a value is only a numeric value + +sub only_num { + + my ($fm, $value) = @_; + my $self = shift; + my $return_error = $self->localise('NOT_NUM'); + + if ($value =~ /^\d+$/){ + return "OK"; + } + else { + return $return_error; + } +} + +sub print_message { + + my ($fm, $word) = @_; + $word = $fm->localise($word); + print qq($word); + return undef; + +} \ No newline at end of file diff -urN smeserver-zarafa-0.9.0.orig/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/zarafaUI.pm smeserver-zarafa-0.9.0/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/zarafaUI.pm --- smeserver-zarafa-0.9.0.orig/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/zarafaUI.pm 1970-01-01 10:00:00.000000000 +1000 +++ smeserver-zarafa-0.9.0/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/zarafaUI.pm 2009-06-01 21:15:18.000000000 +1000 @@ -0,0 +1,1934 @@ +#!/usr/bin/perl -w + +package esmith::FormMagick::Panel::zarafaUI; + + use strict; + use warnings; + use esmith::ConfigDB; + use esmith::AccountsDB; + use esmith::FormMagick; + use esmith::cgi; + use File::Basename; + use esmith::util; + use Exporter; + use esmith::DB; + + our $accountdb = esmith::AccountsDB->open(); + our $configdb = esmith::ConfigDB->open(); + + our @ISA = qw(esmith::FormMagick Exporter); + + our @EXPORT = qw(); + + our $VERSION = sprintf '%d.%03d', q$Revision: 1.1 $ =~ /: (\d+).(\d+)/; + + + our $multicompany_enabled; + open(LIRE, "/etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg"); + while(){ + my $ligne = $_; + if($ligne =~ m/^enable_hosted_zarafa/){ + $multicompany_enabled = $ligne; + $multicompany_enabled =~ s/enable_hosted_zarafa\s+\=\s//g; + } + } + close(LIRE); + + +# Ce fichier contient les fonction nécessaire pour gérer l'interface entre le serveur SME et la configuration des utilisateurs +# et des groupes du module Zarafa. +# Ce fichier regroupe des fonctions d'affichage, de modifications et de vérifications de données contenu dans Zarafa. +################################################################################################################################# +# This file contains the required functions in order to handle the interface between SME server and Zarafa configuration module's +# for users and groups. +# It contains display, modify, create and verification functions for Zarafa. + + +# La fonction show_users permet d'afficher un tableaux reprenant l'enssemble des utilisateurs de Zarafa sur la page principale +# avec possibilité de supprimer et de modifier les utilisateurs présents. +############################################################################################################################################## +# The show_users function allow you to display an array which contains all the users of zarafa with links to modify and delete users functions + +sub show_users { + + my $self = shift; + my $q = $self->{cgi}; + + if ($multicompany_enabled =~ m/false/){ + + # Initialisation + my $ligne = 5; + my $nbrligne = `zarafa-admin -l | wc -l`; + my $scriptname = basename($0); + + # Localisation + my $username = $self->localise('USERNAME'); + my $fullname = $self->localise('FULLNAME'); + my $delete = $self->localise('DELETE'); + + # Affichage de l'en-tête du tableau + # Display of the header + print " \n \n "; + print $q->start_table ({-CLASS => "sme-border"}),"\n "; + print $q->Tr( + esmith::cgi::genSmallCell($q, $username,"header"), + esmith::cgi::genSmallCell($q, $fullname,"header"), + esmith::cgi::genSmallCell($q, $delete,"header")); + + + # Affichage des utilisateurs et des liens correspondants + # Display users and corresponding links + my @usertab; + my $nbr = 0; + while ($ligne < $nbrligne) { + $usertab[$nbr] = `zarafa-admin -l | cut -f2 | awk 'NR == $ligne'`; + $ligne ++; + $nbr ++; + } + my @out = sort @usertab; + foreach my $user (@out){ + chomp $user; + if ($user =~ /^([-\@\w.]+)$/) { + $user = $1; # $data now untainted + } + else { + die "bad data in $user"; + } + my $modify = "$user"; + my $delete_user = "$delete"; + print $q->Tr( + esmith::cgi::genSmallCell($q,$modify ,"normal")," ", + esmith::cgi::genSmallCell($q, `zarafa-admin --details \"$user\" | cut -f3 | awk 'NR == 2'`,"normal"), + esmith::cgi::genSmallCell($q,$delete_user,"normal")); + } + + + print qq(\n); + + # Localisation + my $add_user = $self->localise('ADD_USER'); + my $add_user_bubble = $self->localise('ADD_USER_BUBBLE'); + + # Affichage bouton ajouter utilisateur + # Display the user's create button + my $out ="

$add_user

"; + + + return $out; + } + + elsif ($multicompany_enabled =~ m/true/){ + + # Initialisation + my $ligne = 4; + my $nbrligne = `zarafa-admin --list-companies | wc -l`; + $nbrligne ++; + my $scriptname = basename($0); + + # Localisation + my $companyname = $self->localise('COMPANYNAME'); + my $delete = $self->localise('DELETE'); + + # Affichage de l'en-tête du tableau + # Display of the header + print " \n \n "; + print $q->start_table ({-CLASS => "sme-border"}),"\n "; + print $q->Tr( + esmith::cgi::genSmallCell($q, $companyname,"header"), + esmith::cgi::genSmallCell($q, $delete,"header")); + + # Affichage des utilisateurs et des liens correspondants + # Display users and corresponding links + my @usertab; + my $nbr = 0; + while ($ligne < $nbrligne) { + $usertab[$nbr] = `zarafa-admin --list-companies | cut -f2 | awk 'NR == $ligne'`; + $ligne ++; + $nbr ++; + } + my @out = sort @usertab; + foreach my $company (@out){ + chomp $company; + if ($company =~ /^([-\@\w.]+)$/) { + $company = $1; # $data now untainted + } + else { + die "bad data in $company"; + } + my $modify = "$company"; + my $delete_company = "$delete"; + print $q->Tr( + esmith::cgi::genSmallCell($q,$modify ,"normal")," ", + esmith::cgi::genSmallCell($q,$delete_company,"normal")); + } + + + print qq(\n); + + # Localisation + my $add_comp = $self->localise('ADD_COMP'); + my $add_comp_bubble = $self->localise('ADD_COMP_BUBBLE'); + + # Affichage bouton ajouter utilisateur + # Display the user's create button + my $out ="

$add_comp

"; + + return $out; + } +} + +# La fonction transfer_page est requise lors de l'utilisation de lien afin de renvoyer l'utilisateur sur la bonne page. +# Elle récupére le nom de la page demandé et redirige automatiquement l'utilisateur. +############################################################################################################################# +# The transfer_page function is use when the user do an action which need another page in order to redirect to the next page. + +sub transfer_page { + + my ($self, $next_page) = @_; + + $self->{cgi}->param(-name => 'wherenext', -value => $next_page); + +} + +# display_user_details affiche les détails de l'utilisateur passé en paramétre dans des champs modifiables +########################################################################################################## +# display_user_details display the details of the username pass in parameter into editable fields. + +sub display_user_details { + + + my $self = shift; + my $cgi = $self->{cgi}; + + # Récupération du nom de l'utilisateur et vérification de sa fiabilité + # recovery of the username and test is reliability + my $recept_user = $cgi->param('actUsr'); + if ($recept_user =~ /^([-\@\w.]+)$/) { + $recept_user = $1; # $data now untainted + } + else { + die "Bad data in '$recept_user'"; + } + my ($user, $Emailaddress, $active, $admin, $meeting_req, $quota_overr, + $warnlvl, $softlvl, $hardlvl, $store_size, $decline_dbl, $decline_recur); + + # Récupération des informations de l'utilisateur + # recovery of user's information + open(DETAILS, "zarafa-admin --details \"$recept_user\" |") or die "probléme ouverture fichier"; + while (
){ + if(m/^Fullname/){ + $user = $_; + $user =~ s/^\w+:\t*//; + } + if(m/^Emailaddress/){ + $Emailaddress = $_; + $Emailaddress =~ s/^\w+:\t*//; + } + if(m/^Active/){ + $active = $_; + chomp $active; + $active =~ s/^\w+:\t*//; + } + if(m/^Administrator/){ + $admin = $_; + chomp $admin; + $admin =~ s/^\w+:\t*//; + } + if(m/^Auto-accept/){ + $meeting_req = $_; + chomp $meeting_req; + $meeting_req =~ s/.+://; + } + if(m/^Decline dbl/){ + $decline_dbl = $_; + chomp $decline_dbl; + $decline_dbl =~ s/Decline dbl meetingreq:\t*//; + } + if(m/^Decline recur/){ + $decline_recur = $_; + chomp $decline_recur; + $decline_recur =~ s/Decline recur meet\.req:\t*//; + } + if(m/^Quota overrides/){ + $quota_overr = $_; + chomp $quota_overr; + $quota_overr =~ s/Quota overrides:\t*//; + } + if(m/^Warning level/){ + $warnlvl = $_; + chomp $warnlvl; + $warnlvl =~ s/Warning level:\t*//; + if($warnlvl =~ m/KB/){ + $warnlvl =~ s/.{3}$//g; + $warnlvl = $warnlvl / 1024; + } + } + if(m/^Soft level/){ + $softlvl = $_; + chomp $softlvl; + $softlvl =~ s/Soft level:\t*//; + if($softlvl =~ m/KB/){ + $softlvl =~ s/.{3}$//g; + $softlvl = $softlvl / 1024; + } + } + if(m/^Hard level/){ + $hardlvl = $_; + chomp $hardlvl; + $hardlvl =~ s/Hard level:\t*//; + if($hardlvl =~ m/KB/){ + $hardlvl =~ s/.{3}$//g; + $hardlvl = $hardlvl / 1024; + } + } + if(m/^Current store size/){ + $store_size = $_; + chomp $store_size; + $store_size =~ s/Current store size:\t*//; + if($store_size =~ m/B/){ + $store_size =~ s/\sB//i; + $store_size /= 1048576; + $store_size =~ s/(\.\d{5})\d*/$1/; + $store_size .= " Mo"; + } + if($store_size =~ m/KB/){ + $store_size =~ s/\sKB//i; + $store_size /= 1024; + $store_size .= " Mo"; + } + } + } + close(DETAILS); + + # Vérification de la présence de l'utilisateur dans la BD serveur + # Verify if the user is in the Server's DB + my $zarafa_text = $self->localise('CAUTION_NOT_DB'); + my $present = 0; + + my $test = $accountdb->get("$recept_user"); + if($test){ + $zarafa_text = $self->localise('IN_DB'); + $present = 1; + } + + # Remplissage des champs de l'interface avec les données récupérés + # Filling of user's field with the previous data + $cgi->param(-name=>'Username', -value=>$recept_user); + $cgi->param(-name=>'Fullname', -value=>$user); + $cgi->param(-name=>'EmailAddress', -value=>$Emailaddress); + $cgi->param(-name=>'Admin', -value=>$admin); + $cgi->param(-name=>'quota', -value=>$quota_overr); + $cgi->param(-name=>'Warnlvl', -value=>$warnlvl); + $cgi->param(-name=>'Softlvl', -value=>$softlvl); + $cgi->param(-name=>'Hardlvl', -value=>$hardlvl); + $cgi->param(-name=>'auto_meeting_req', -value=>$meeting_req); + $cgi->param(-name=>'dbl_meeting', -value=>$decline_dbl); + $cgi->param(-name=>'decline_recur_meeting', -value=>$decline_recur); + + # Localisation + my $enabled = $self->localise('ENABLED'); + my $disabled = $self->localise('DISABLED'); + + + # Affichage de l'option zarafa pour ceux qui sont dans la BD + # Display of the zarafa's button if the user is in the server's DB + my $zarafa_status; + my $out; + if($present == 1){ + unless($configdb->get_prop("zarafa-server",'GlobalForward')){ + $zarafa_status = $accountdb->get_prop("$recept_user",'zarafa'); + + $out = "\n " + . "Zarafa" + . "\n \n" + . " \n"; + if($zarafa_status){ + $out .="" + ."\n" + ."\n"; + } + else { + $out .="" + ."\n" + ."\n"; + } + $out .= "
$enabled$disabled
$enabled$disabled
\n \n \n"; + } + + + # Affichage de l'option SortSpam pour ceux qui sont dans la BD + # Display of the SortSpam's button if the user is in the server's DB + my $sortspam = $accountdb->get_prop("$recept_user",'SortSpam'); + $out .= "\n " + . "SortSpam" + . "\n \n" + . " \n"; + if($sortspam){ + $out .="" + ."\n"; + } + else { + $out .="" + ."\n"; + } + $out .= "
$enabled
$enabled
\n \n \n"; + } + + + # Localisation + # Localization + my $details = $self->localise('DETAILS'); + my $stock_use = $self->localise('STOCK_USE'); + my $active_user = $self->localise('ACTIVE_USER'); + + print "$details $recept_user - $user - $stock_use $store_size $active_user $active - $zarafa_text"; + +return $out; +} + +# display_modify_button permet l'affichage d'un bouton 'Modify' +############################################################################ +# display_modify_button is use to display a button with 'modify' text inside + +sub display_modify_button { + + my ($self) = @_; + + my $cgi = $self->{cgi}; + + my $button = $self->localise('MODIFY_BUTTON'); + + $self->print_button("$button"); + +} + +# display_create_button permet l'affichage d'un bouton 'Create' +############################################################################ +# display_create_button is use to display a button with 'Create' text inside + +sub display_create_button { + + my ($self) = @_; + my $cgi = $self->{cgi}; + + my $button = $self->localise('CREATE_BUTTON'); + $self->print_button("$button"); +} + +# display_delete_button permet l'affichage d'information sur l'utilisateur ainsi qu'un bouton 'Delete' +###################################################################################################### +# display_delete_button is use to display some user information and a button with 'Delete' text inside + +sub display_delete_button { + + my ($self) = @_; + my $cgi = $self->{cgi}; + + my $recept_user = $cgi->param('actUsr'); + if ($recept_user =~ /^([-\@\w.]+)$/) { + $recept_user = $1; # $data now untainted + } + else { + die "Bad data in '$recept_user'"; + } + + my $user = `zarafa-admin --details $recept_user | awk 'NR == 2'`; + $user =~ s/Fullname:\t\t//g; + + my $store_size = `zarafa-admin --details $recept_user | awk 'NR == 11'`; + $store_size =~ s/Current store size:\t//g; + if($store_size =~ m/B/){ + $store_size =~ s/\sB//i; + $store_size /= 1048576; + $store_size .= " Mb"; + } + if($store_size =~ m/KB/){ + $store_size =~ s/\sKB//i; + $store_size /= 1024; + $store_size .= " Mb"; + } + + + my $active = `zarafa-admin --details $recept_user | awk 'NR == 4'`; + $active =~ s/Active:\t\t\t//g; + + + # Localisation + # Localization + my $details = $self->localise('DETAILS'); + my $stock_use = $self->localise('STOCK_USE'); + my $active_user = $self->localise('ACTIVE_USER'); + my $button = $self->localise('DELETE_BUTTON'); + + print "$details $recept_user - $user - $stock_use $store_size - $active_user $active"; + + $self->print_button("$button"); +} + +# La fonction modify_user récupére le contenu de multiple champs afin de mettre à jour le contenu de Zarafa +########################################################################################################### +# The modify_user function recover the content of multiple fields in order to update Zarafa's content + +sub modify_user { + + my ($self) = @_; + my $cgi = $self->{cgi}; + + # Récupération de l'utilisateur à modifier + # Recovery of the user for modified + my $user = $cgi->param('actUsr'); + if ($user =~ /^([-\@\w.]+)$/) { + $user = $1; # $data now untainted + } + else { + die "bad data in $user"; + } + + # Récupération du contenu des champs + # Recovery of fields contents + my $user_id = $self->{cgi}->param('Username'); + if ($user_id =~ /^([-\@\w.]+)$/) { + $user_id = $1; # $data now untainted + } + else { + die "Bad data in '$user_id'"; + } + + my $user_fullname = $self->{cgi}->param('Fullname'); + chomp $user_fullname; + $user_fullname =~ s/ /@/g; + if ($user_fullname =~ /^([-\@\w.]+)$/) { + $user_fullname = $1; # $data now untainted + } + else { + die "Bad data in '$user_fullname'"; + } + $user_fullname =~ s/@/ /g; + $user_fullname = "\"".$user_fullname."\""; + + my $user_address = $self->{cgi}->param('EmailAddress'); + if ($user_address =~ /^([-\@\w.]+)$/) { + $user_address = $1; # $data now untainted + } + else { + die "Bad data in '$user_address'"; + } + + my $user_admin = $self->{cgi}->param('Admin'); + if ($user_admin =~ /^([-\@\w.]+)$/) { + $user_admin = $1; # $data now untainted + } + else { + die "Bad data in '$user_admin'"; + } + + my $user_quota = $self->{cgi}->param('quota'); + if ($user_quota =~ /^([-\@\w.]+)$/) { + $user_quota = $1; # $data now untainted + } + else { + die "Bad data in '$user_quota'"; + } + + my $user_warnlvl = $self->{cgi}->param('Warnlvl'); + unless ($user_warnlvl) + {$user_warnlvl = 0;} + if ($user_warnlvl =~ /^([-\@\w.]+)$/) { + $user_warnlvl = $1; # $data now untainted + } + else { + die "Bad data in '$user_warnlvl'"; + } + + my $user_softlvl = $self->{cgi}->param('Softlvl'); + unless ($user_softlvl) + {$user_softlvl = 0;} + if ($user_softlvl =~ /^([-\@\w.]+)$/) { + $user_softlvl = $1; # $data now untainted + } + else { + die "Bad data in '$user_softlvl'"; + } + + + my $user_hardlvl = $self->{cgi}->param('Hardlvl'); + unless ($user_hardlvl) + {$user_hardlvl = 0;} + if ($user_hardlvl =~ /^([-\@\w.]+)$/) { + $user_hardlvl = $1; # $data now untainted + } + else { + die "Bad data in '$user_hardlvl'"; + } + + + my $user_meeting = $self->{cgi}->param('auto_meeting_req'); + if ($user_meeting =~ /^([-\@\w.]+)$/) { + $user_meeting = $1; # $data now untainted + } + else { + die "Bad data in '$user_meeting'"; + } + + my $user_dbl = $self->{cgi}->param('dbl_meeting'); + if ($user_dbl =~ /^([-\@\w.]+)$/) { + $user_dbl = $1; + } + else { + die "Bad data in '$user_dbl'"; + } + + my $user_recur_meeting = $self->{cgi}->param('decline_recur_meeting'); + if ($user_recur_meeting =~ /^([-\@\w.]+)$/) { + $user_recur_meeting = $1; + } + else { + die "Bad data in '$user_recur_meeting'"; + } + + + # Récupération d'un nouveau mot de passe et remplacement de l'ancien + # Recovery of a new password and replacement of the old password + my $user_new_password = $self->{cgi}->param('new_password'); + if ($user_new_password){ + if ($user_new_password =~ /^([-\@\w.]+)$/) { + $user_new_password = $1; + } + else { + die "Bad data in '$user_new_password'"; + } + system("zarafa-admin -u $user -p $user_new_password > /dev/null") == 0 + or die "Une erreur est survenue lors du changement de password de l'utilisateur $user"; + } + + my $fm = shift; + my $q = $fm->{'cgi'}; + + my $zarafa_enabled = $q->param('zarafa'); + if($zarafa_enabled){ + if($zarafa_enabled eq 'enabled'){ + system("/sbin/e-smith/db accounts setprop \"$user_id\" zarafa enabled"); + system("/etc/e-smith/events/actions/qmail-update-user"); + + } + elsif($zarafa_enabled eq 'disabled'){ + system("/sbin/e-smith/db accounts delprop \"$user_id\" zarafa"); + system("/etc/e-smith/events/actions/qmail-update-user"); + } + } + + # Ajout des modifications dans la base de données Zarafa + # Modify information added into Zarafa database + if ($user eq $user_id){ + system("zarafa-admin -u $user -f $user_fullname -e $user_address -a $user_admin --qo $user_quota --qw $user_warnlvl --qs $user_softlvl --qh $user_hardlvl --mr-accept $user_meeting --mr-decline-conflict $user_dbl --mr-decline-recurring $user_recur_meeting > /dev/null") == 0 + or die "Une erreur est survenue lors de la modification de l'utilisateur"; + } + else { + system("zarafa-admin -u $user -U $user_id -f $user_fullname -e $user_address -a $user_admin --qo $user_quota --qw $user_warnlvl --qs $user_softlvl --qh $user_hardlvl --mr-accept $user_meeting --mr-decline-conflict $user_dbl --mr-decline-recurring $user_recur_meeting> /dev/null") == 0 + or die "Une erreur est survenue lors de la modificatoin de l'utilisateur"; + } + + + my $sortspam = $q->param('sortspam'); + if($sortspam eq 'enabled'){ + system("/sbin/e-smith/db accounts setprop \"$user_id\" SortSpam disabled"); + system("/sbin/e-smith/signal-event user-modify \"$user_id\""); + } + else{ + system("/sbin/e-smith/db accounts delprop \"$user_id\" SortSpam"); + system("/sbin/e-smith/signal-event user-modify \"$user_id\""); + } + + # Opération sur les groupes d'utilisateurs + # Operation on user's groups + my $eval = ""; + # Parcours de la liste des groupes + # Browse of the group liste + open(LISTGRP, "zarafa-admin -L | awk 'NR > 4' |"); + while(){ + my $groupeparam = $_; + $groupeparam =~ s/^\t//g; + chomp $groupeparam; + $groupeparam =~ s/ /_/g; + if ($groupeparam =~ /^([-\@\w.]+)$/) { + $groupeparam = $1; + } + else { + $groupeparam = $1; + } + + my $present = 0; + if($groupeparam){ + $groupeparam =~ s/_/ /g; + unless ($eval eq $groupeparam){ + # Si le bouton radio est sur oui ... + # If the radio button is 'on' ... + my $yesNo = $q->param("$groupeparam"); + if($yesNo eq 'Yes'){ + # On regarde si l'utilisateur est déja dans le groupe ... + # The user is allready in the group ? ... + open(ADDUSR, "zarafa-admin -l --details \"$groupeparam\" --type group |"); + while(){ + if(m/^\t$user/){ + $present = 1; + } + } + # Si il n'y est pas on le rajoute + # If it's not in the group, add it + unless($present == 1){ + system("zarafa-admin -b $user -i \"$groupeparam\" > /dev/null") == 0 + or die "Impossible de rajouter l'utilisateur $user dans le groupe $groupeparam"; + } + } + close(ADDUSR); + # Si le bouton radio est sur non ... + # If the radio button is 'off'... + if($yesNo eq 'No'){ + # On regarde si l'utilisateur est dans le groupe ... + # Is the user in the group ? ... + open(DELUSR, "zarafa-admin -l --details \"$groupeparam\" --type group |"); + while(){ + if(m/^\t$user/){ + $present = 1; + } + } + # Si il y est on l'en enléve + # If it's in, remove it + if($present == 1){ + system("zarafa-admin -B $user -i \"$groupeparam\" > /dev/null") == 0 + or die "Impossible de supprimer l'utilisateur $user du groupe $groupeparam"; + } + close(DELUSR); + } + $eval = $groupeparam; + } + } + } + close(LISTGRP); + + $self->success('MODIFY_USER_SUCCESS'); + +# Option possible pour mettre à jour ou créer des utilisateurs avec zarafa-admin +# Zarafa-admin option for update and creation for users +#-U username +#-p password +#-f fullname +#-e emailaddress +#-a admin +#-n active user +#--qo quota override +#--qw quota warning +#--qs quota soft +#--qh quota hard +#--mr-accept meeting request +#--mr-decline-conflict +#--mr-decline-recurring +} + +# La fonction Create_user récupére le contenu de plusieurs champs afin de créer un utilisateurs zarafa avec ces derniers +######################################################################################################################## +# The Create_user function recover the content of many fields in order to create a zarafa's user with them + +sub Create_user { + + my ($self) = @_; + my $cgi = $self->{cgi}; + + # Récuperation du contenu des champs + # Recovery of content's fields + my $user_id = $self->{cgi}->param('Username'); + if ($user_id =~ /^([-\@\w.]+)$/) { + $user_id = $1; # $data now untainted + } + else { + die "Bad data in $user_id"; + } + + my $user_fullname = $self->{cgi}->param('Fullname'); + chomp $user_fullname; + $user_fullname =~ s/ /@/g; + if ($user_fullname =~ /^([-\@\w.]+)$/) { + $user_fullname = $1; # $data now untainted + } + else { + die "Bad data in '$user_fullname'"; + } + $user_fullname =~ s/@/ /g; + $user_fullname = "\"".$user_fullname."\""; + + my $user_psswrd = $self->{cgi}->param('Password'); + if ($user_psswrd =~ /^([-\@\w.]+)$/) { + $user_psswrd = $1; # $data now untainted + } + else { + die "Bad data in '$user_psswrd'"; + } + + my $user_address = $self->{cgi}->param('EmailAddress'); + if ($user_address =~ /^([-\@\w.]+)$/) { + $user_address = $1; # $data now untainted + } + else { + die "Bad data in '$user_address'"; + } + + my $user_admin = $self->{cgi}->param('Admin'); + if ($user_admin =~ /^([-\@\w.]+)$/) { + $user_admin = $1; # $data now untainted + } + else { + die "Bad data in '$user_admin'"; + } + + my $user_quota = $self->{cgi}->param('quota'); + if ($user_quota =~ /^([-\@\w.]+)$/) { + $user_quota = $1; # $data now untainted + } + else { + die "Bad data in '$user_quota'"; + } + + my $user_warnlvl = $self->{cgi}->param('Warnlvl'); + unless ($user_warnlvl) + {$user_warnlvl = 0;} + if ($user_warnlvl =~ /^([-\@\w.]+)$/) { + $user_warnlvl = $1; # $data now untainted + } + else { + die "Bad data in '$user_warnlvl'"; + } + + + my $user_softlvl = $self->{cgi}->param('Softlvl'); + unless ($user_softlvl) + {$user_softlvl = 0;} + if ($user_softlvl =~ /^([-\@\w.]+)$/) { + $user_softlvl = $1; # $data now untainted + } + else { + die "Bad data in '$user_softlvl'"; + } + + + my $user_hardlvl = $self->{cgi}->param('Hardlvl'); + unless ($user_hardlvl) + {$user_hardlvl = 0;} + if ($user_hardlvl =~ /^([-\@\w.]+)$/) { + $user_hardlvl = $1; # $data now untainted + } + else { + die "Bad data in '$user_hardlvl'"; + } + + my $user_active = $self->{cgi}->param('Active'); + if ($user_active =~ /^([-\@\w.]+)$/) { + $user_active = $1; # $data now untainted + } + else { + die "Bad data in '$user_active'"; + } + + # Création de l'utilisateur + # User's creation + system("zarafa-admin -c $user_id -f $user_fullname -p $user_psswrd -e $user_address -a $user_admin -n $user_active --qo $user_quota --qw $user_warnlvl --qs $user_softlvl --qh $user_hardlvl > /dev/null") == 0 + or die "Une erreur est survenue lors de la création de l'utilisateur"; + + # Ajout dans la BD Accounts du serveur SME + system("/sbin/e-smith/db accounts setprop \"$user_id\" zarafa enabled"); + system("/etc/e-smith/events/actions/qmail-update-user"); + + + # Attribution des groupes + # groups allocation + my $fm = shift; + my $q = $fm->{'cgi'}; + + my $eval = ""; + # Parcours de la liste des groupes + # Browse groups' list + open(LISTGRP, "zarafa-admin -L | awk 'NR > 4' |"); + while(){ + my $groupeparam = $_; + $groupeparam =~ s/^\t//g; + chomp $groupeparam; + $groupeparam =~ s/ /_/g; + if ($groupeparam =~ /^([-\@\w.]+)$/) { + $groupeparam = $1; + } + else { + $groupeparam = $1; + } + $groupeparam =~ s/_/ /g; + if($groupeparam){ + unless ($eval eq $groupeparam){ + my $yesNo = $q->param("$groupeparam"); + # Si le bouton radio est sur oui, on ajoute l'utilisateur au groupe + # If the radio button is 'on', the user is added to the group + if($yesNo eq 'Yes'){ + system("zarafa-admin -b $user_id -i \"$groupeparam\" > /dev/null") == 0 + or die "Impossible de rajouter l'utilisateur $user_id dans le groupe $groupeparam"; + } + } + $eval = $groupeparam; + } + } + close(LISTGRP); + + $self->success('CREATE_USER_SUCCESS'); + +} + +# delete_user permet de supprimer un utilisateur de la base de données Zarafa +############################################################################# +# delete_user is use to delete an user from the Zarafa database + +sub delete_user { + + my ($self) = @_; + my $cgi = $self->{cgi}; + + my $user = $cgi->param('actUsr'); + if ($user =~ /^([-\@\w.]+)$/) { + $user = $1; # $data now untainted + } + else { + die "Bad data in '$user'"; + } + + system("zarafa-admin -d $user > /dev/null") == 0 + or die "Impossible de supprimer cet utilisateur."; + + # Suppression dans la BD Accounts du serveur SME + system("/sbin/e-smith/db accounts delprop \"$user\" zarafa enabled"); + system("/etc/e-smith/events/actions/qmail-update-user"); + + $self->success('DELETE_USER_SUCCESS'); + +} + +# modify_user_groups affiche une liste de tout les groupes et indique si l'utilisateur dont il est question appartient au groupe ou non +####################################################################################################################################### +# modify_user_groups display a list of all groups and show if the user belongs to groups or not + +sub display_user_groups { + + my ($self) = @_; + my $cgi = $self->{cgi}; + +if ($multicompany_enabled =~ m/false/){ + # Récupération du nom d'utilisateur + # Recover username + my $user = $cgi->param('actUsr'); + if ($user =~ /^([-\@\w.]+)$/) { + $user = $1; # $data now untainted + } + else { + die "Bad data in '$user'"; + } + + my $fm = shift; + my $groups; + my $eval = ""; + my $checkedYes = ""; + my $display_group = $self->localise('GROUP_TEXT_DISPLAY'); + + my $out = "\n " + . "$display_group" + . "\n \n" + . " \n"; + + # Parcours de la liste des groupes + # Browse groups' list + open(LIRE, "zarafa-admin -L | awk 'NR > 3' |"); + while(){ + $groups = $_; + $groups =~ s/^\t//g; + $groups =~ s/ /_/g; + chomp $groups; + if($groups){ + # Si groupe existe ... + # If group exist ... + if ($groups =~ /^([-\@\w.]+)$/) { + $groups = $1; # $data now untainted + } + else { + $groups = $1; + } + $groups =~ s/_/ /g; + # On ne soccupe pas du groupe 'Everyone' + # The 'Everyone' group doesn't be display + unless($groups eq 'Everyone'){ + # Si l'utilisateur est dans le groupe alors le bouton sera 'checked' + # If the user is in the group, the button will be 'checked' + open(GRP, "zarafa-admin --details \"$groups\" --type group |"); + while(){ + if(m/$user\t{1}/){ + $checkedYes = "checked"; + } + } + close(GRP); + unless($eval =~ m/$groups/){ + my $yes = $self->localise('CHECKED_YES'); + my $no = $self->localise('CHECKED_NO'); + # Affichage si le bouton 'oui' est 'checked' + # Display if the 'yes' button is 'checked' + if($checkedYes eq "checked") { + $out .="\n \n" + ."" + ."\n" + ."\n"; + } + # Affichage si le bouton 'non' est 'checked' + # Display if the 'no' button is 'checked' + else { + $out .="\n \n" + ."" + ."\n" + ."\n"; + } + $checkedYes = ""; + } + $eval = $groups; + } + } + } + + $out .= "
$groups : $yes$no
$groups : $yes$no
\n \n \n"; + close(LIRE); + return $out; + } + +elsif ($multicompany_enabled =~ m/true/){ + + # Récupération du nom d'utilisateur + # Recover username + my $user = $cgi->param('actUsr'); + if ($user =~ /^([-\@\w.]+)$/) { + $user = $1; # $data now untainted + } + else { + die "Bad data in '$user'"; + } + + my $fm = shift; + my $groups; + my $eval = ""; + my $checkedYes = ""; + my $display_group = $self->localise('GROUP_TEXT_DISPLAY'); + + my $out = "\n " + . "$display_group" + . "\n \n" + . " \n"; + + # Parcours de la liste des groupes + # Browse groups' list + open(LIRE, "zarafa-admin -L |"); + while(){ + $groups = $_; + $groups =~ s/^\t//g; + $groups =~ s/ /_/g; + chomp $groups; + if($groups){ + # Si groupe existe ... + # If group exist ... + if ($groups =~ /^([-\@\w.]+)$/) { + $groups = $1; # $data now untainted + } + else { + $groups = $1; + } + $groups =~ s/_/ /g; + # On ne soccupe pas du groupe 'Everyone' + # The 'Everyone' group doesn't be display + unless($groups =~ m/Everyone/ or $groups =~ m/Group list for/ or $groups =~ m/------/ or !$groups or $groups =~ m/groupname/){ + # Si l'utilisateur est dans le groupe alors le bouton sera 'checked' + # If the user is in the group, the button will be 'checked' + open(GRP, "zarafa-admin --details \"$groups\" --type group |"); + while(){ + if(m/$user/){ + $checkedYes = "checked"; + } + } + close(GRP); + unless($eval =~ m/$groups/){ + my $yes = $self->localise('CHECKED_YES'); + my $no = $self->localise('CHECKED_NO'); + # Affichage si le bouton 'oui' est 'checked' + # Display if the 'yes' button is 'checked' + if($checkedYes eq "checked") { + $out .="\n \n" + ."" + ."\n" + ."\n"; + } + # Affichage si le bouton 'non' est 'checked' + # Display if the 'no' button is 'checked' + else { + $out .="\n \n" + ."" + ."\n" + ."\n"; + } + $checkedYes = ""; + } + $eval = $groups; + } + } + } + + $out .= "
$groups : $yes$no
$groups : $yes$no
\n \n \n"; + close(LIRE); + return $out; + } + +} + +# Create_group permet la création de groupe d'utilisateur en récupérant un nom saisi par l'utilisateur +###################################################################################################### +# Create_group allow to create an user's group with a name recover from the user + +sub Create_group { + + my ($self) = @_; + my $cgi = $self->{cgi}; + + # Récuperation du nom de groupe + # Recover the groupname + my $group = $self->{cgi}->param('Groupname'); + $group =~ s/ /_/g; + if ($group =~ /^([-\@\w.]+)$/) { + $group = $1; # $data now untainted + } + else { + die "Bad data in '$group'"; + } + $group =~ s/_/ /g; + + + # Création du groupe + # Group creation + system("zarafa-admin -g \"$group\" > /dev/null") == 0 + or die "Impossible de créer le groupe"; + + $self->success('CREATE_GROUP_SUCCESS'); + +} + +# show_group affiche une liste de tout les groupe dans un tableau avec un lien pour les modifier et un autre pour les supprimer +############################################################################################################################### +# show_group display a list of all groups into an array with two links in order to modify an delete them + +sub show_group { + + my $self = shift; + my $q = $self->{cgi}; + + + if ($multicompany_enabled =~ m/false/){ + + my $nbrligne = `zarafa-admin -L | wc -l`; + my $scriptname = basename($0); + my $ligne = 4; + + # Localisation + # Localization + my $groupname = $self->localise('GROUP_NAME_ARRAY'); + my $suppr = $self->localise('DELETE'); + + # Affichage de l'en-tête du tableau + # Display the header + print " \n \n "; + print $q->start_table ({-CLASS => "sme-border"}),"\n "; + print $q->Tr( + esmith::cgi::genSmallCell($q, $groupname,"header"), + esmith::cgi::genSmallCell($q, $suppr,"header")); + + # Parcours de la liste des groupes avec affichage dans le tableau de chacun, création et affichage des liens correspondant + # Browse the group's list and display them into the array, create and diplay the links + my @grouptab; + my $nbr = 0; + while ($ligne < $nbrligne) { + $grouptab[$nbr] = `zarafa-admin -L | awk 'NR == $ligne'`; + $nbr ++; + $ligne ++; + } + + my @out = sort @grouptab; + foreach my $group (@out){ + unless($group =~ m/^\tEveryone/){ + my $delete = "$suppr"; + my $modify = "$group"; + print $q->Tr( + esmith::cgi::genSmallCell($q,$modify ,"normal")," ", + esmith::cgi::genSmallCell($q,$delete,"normal")); + } + } + + print qq(\n); + + my $add_group = $self->localise('ADD_GROUP'); + my $add_group_bubble = $self->localise('ADD_GROUP_BUBBLE'); + + my $out ="

$add_group

"; + + + return $out; + } + + else { + return 0; + } +} + +# delete_group permet de supprimer un groupe passé en paramétre +############################################################### +# delete_group is use to delete the group passed in parameter + +sub delete_group { + + my ($self) = @_; + my $cgi = $self->{cgi}; + + # Récupération du nom du groupe + # Recover the groupname + my $group = $cgi->param('actGrp'); + $group =~ s/ /_/g; + if ($group =~ /^([-\@\w.]+)$/) { + $group = $1; # $data now untainted + } + else { + die "Bad data in '$group'"; + } + $group =~ s/_/ /g; + + # Suppression du groupe + # Deleting group + system("zarafa-admin -G \"$group\" > /dev/null") == 0 + or die "Impossible de supprimer ce groupe."; + + $self->success('DELETE_GROUP_SUCCESS'); + +} + +# Cette fonction affiche un bouton contenant le texte 'Delete' +############################################################# +# Thus function dispay a button with 'Delete' text inside + +sub display_delete_group_button { + + my ($self) = @_; + my $cgi = $self->{cgi}; + + my $group = $cgi->param('actGrp'); + $group =~ s/ /_/g; + if ($group =~ /^([-\@\w.]+)$/) { + $group = $1; # $data now untainted + } + else { + die "Bad data in '$group'"; + } + $group =~ s/_/ /g; + $self->print_button("DELETE"); + +} + +# display_user_in_group affiche la liste de tout les utilisateurs et indique ceux qui appartiennent au groupe passé en paramétre +################################################################################################################################ +# display_user_in_group display a list of all users and show those are in the group passed in parameter, or not + +sub display_user_in_group { + + my $self = shift; + my $cgi = $self->{cgi}; + + # Récupération du nom du groupe + # Recovery of the groupename + my $group = $cgi->param('actGrp'); + $group =~ s/ /_/g; + if ($group =~ /^([-\@\w.]+)$/) { + $group = $1; # $data now untainted + } + else { + die "Bad data in '$group'"; + } + $group =~ s/_/ /g; + + my $grouptext = $self->localise('MODIFY_GROUP_TEXT'); + print "$grouptext $group"; + my ($user, $fullname); + my $out = "\n " + . "$group" + . "\n \n" + . " \n"; + + $group = "\"".$group."\""; + # Parcours de la liste des utilisateurs + # Browse the user list + open(USER, "zarafa-admin -l | awk 'NR > 4' |"); + while(){ + my $ligne = $_; + chomp $ligne; + my $checked = ""; + $user = $ligne; + $fullname = $ligne; + $fullname =~ s/^.*\t{2}//g; + $user =~ s/\t{2}.*$//g; + $user =~ s/^\t{1}//g; + if($fullname){ + # Si l'utilisateur est dans le groupe alors il est 'checked' + # If the user is in the group, he is 'checked' + open(INGRP, "zarafa-admin --details $group --type group |"); + while(){ + if(m/$user\t{1}/){ + $checked = "checked"; + } + } + close(INGRP); + + # Affichage si l'utilisateur est 'checked' + # Display if the user is 'checked' + my $yes = $self->localise('CHECKED_YES'); + my $no = $self->localise('CHECKED_NO'); + if($checked eq 'checked'){ + $out .="\n \n" + ."" + ."\n" + ."\n"; + } + # Affichage si l'utilisateur n'est pas 'checked' + # Display if the user is not 'checked' + else { + $out .="\n \n" + ."" + ."\n" + ."\n"; + } + } + } + close(USER); + $out .= "
$fullname : $yes$no
$fullname : $yes$no
\n \n \n"; + + return $out; + +} + +# display_modify_group_button affiche un bouton contenant 'Modify' pour la gestion des groupes +################################################################################################## +# display_modify_group_button display a button with 'Modify' text specially for group's management + +sub display_modify_group_button { + + my ($self) = @_; + + my $cgi = $self->{cgi}; + + $self->print_button("MODIFY_BUTTON"); + +} + +# Cette fonction permet de modifier les utilisateurs appartenant a un groupe passé en paramétre +############################################################################################### +# This function is use to modify the users belong to a group passed in parameter + +sub modify_user_group { + + my ($self) = @_; + my $cgi = $self->{cgi}; + my $group = $cgi->param('actGrp'); + + my $fm = shift; + my $q = $fm->{'cgi'}; + + # Parcours de la liste des utilisateurs + # Browse the user list + open(LISTUSR, "zarafa-admin -l | awk 'NR > 4' |"); + while(){ + my $user = $_; + $user =~ s/\t{2}.*$//g; + $user =~ s/^\t//g; + chomp $user; + chomp $group; + + if($user){ + if ($user =~ /^([-\@\w.]+)$/) { + $user = $1; + } + else { + die "bad data in $user"; + } + + my $present = 0; + my $yesNo = $q->param("$user"); + # Si le bouton radio est sur 'oui' ... + # If the radio button is 'on' ... + if($yesNo eq 'yes'){ + open(ADDUSR, "zarafa-admin -l --details \"$group\" --type group |"); + while(){ + if(m/^\t$user/){ + $present = 1; + } + } + # Et si l'utilisateur n'est pas dans le groupe, alors on le rajoute + # And if the user is not in the group, then add him into the group + unless($present == 1){ + system("zarafa-admin -b $user -i \"$group\" > /dev/null") == 0 + or die "Impossible de rajouter l'utilisateur $user dans le groupe $group"; + } + close(ADDUSR); + } + # Si le bouton radio est sur 'non' ... + # If the radio button is 'off' ... + if($yesNo eq 'no'){ + open(DELUSR, "zarafa-admin -l --details $user |"); + while(){ + # Et si l'utilisateur appartient au groupe, alors on le supprime du groupe + # And if the user is in the group, then delete him from the group + if(m/^\t$group$/){ + system("zarafa-admin -B $user -i \"$group\" > /dev/null") == 0 + or die "Impossible de supprimer l'utilisateur $user du groupe $group"; + } + } + close(DELUSR); + } + } + } + close(LISTUSR); + + $self->success('MODIFY_GROUP_SUCCESS'); +} + +# display_create_user_group permet d'afficher la liste de tout les groupes en précochant l'apartenance de l'utilisateur à tout les groupes. +# Utilisé pour l'affichage de la création d'un utilisateur. +##################################################################################################################################################### +# display_create_user_group is use to display a list of all group set to 'no' by default for the user. It will be use into the display of create user. + +sub display_create_user_group { + + my ($self) = @_; + my $cgi = $self->{cgi}; + + my $fm = shift; + my $groups; + my $eval = ""; + + my $exist_group = $self->localise('EXIST_GROUP'); + my $out = "\n " + . $exist_group + . "\n \n" + . " \n"; + + # Parcours de la liste des groupes + # Browse group's list + open(LIRE, "zarafa-admin -L | awk 'NR > 3' |"); + while(){ + $groups = $_; + $groups =~ s/^\t//g; + chomp $groups; + $groups =~ s/ /_/g; + if ($groups =~ /^([-\@\w.]+)$/) { + $groups = $1; # $data now untainted + } + else { + $groups = $1; + } + $groups =~ s/_/ /g; + if($groups){ + # Tant que le groupe n'est pas 'Everyone' ... + # Unless the group is 'Everyone' ... + my $yes = $self->localise('CHECKED_YES'); + my $no = $self->localise('CHECKED_NO'); + unless($groups eq 'Everyone'){ + # Affichage des boutons radio du groupe + # Display the radio button's group + unless($eval eq $groups){ + $out .="\n \n" + ."" + ."\n" + ."\n"; + } + $eval = $groups; + } + } + } + + $out .= "
$groups : $yes$no
\n \n \n"; + close(LIRE); + return $out; +} + +# Les fonctions suivantes servent à vérifié se que l'utilisateur saisi dans divers champs, afin d'éviter toute erreur de sa part ou tentative de sabotage de la part de personne malveillante. +############################################################################################################################################################################################## +# The functions below is use to analyse and find error in the fields the user have fill in order to securise the software. + +# Cette fonction est principalement utilisé pour vérifié la composition d'un Nom complet rentré par l'utilisateur, ou bien pour le nom des groupes. +################################################################################################################################################### +# This function is mainly use to verify the composition of a Fullname enter by an user or a group name. + +sub fullname { + + my ($fm, $fullname) = @_; + my $self = shift; + + my $return_error = $self->localise('FULLNAME_VERIF_ERROR'); + if ($fullname =~ m/^\w+((\.|\-|\s+)?\w+)*$/){ + return "OK"; + } + else { + return $return_error; + } +} + +# Cette fonction est principalement utilisé pour vérifié la composition d'un mot de passe saisi par l'utilisateur +################################################################################################################# +# This function is mainly use to verify the composition of a password enter by an user. + +sub my_password { + + my ($fm, $password, $minlength) = @_; + my $self = shift; + my $return_error = $self->localise('MY_PASSWORD_VERIF_ERROR'); + if ($password =~ /^\w+$/i and length($password) >= $minlength){ + return "OK"; + } + elsif($password eq ''){ + return "OK"; + } + else { + return $return_error; + } +} + +# quota_test est utilisé pour testé si la valeur des quota saisi par l'utilisateur sont des valeurs correcte. +############################################################################################################# +# quota_test is use in order to test if the user has enter a correct value into quota fields + +sub quota_test { + + my ($fm, $quotalvl) = @_; + my $self = shift; + my $return_error = $self->localise('QUOTA_TEST_VERIF_ERROR'); + if ($quotalvl =~ /^\d*$/ or $quotalvl =~ m/unlimited/i){ + return "OK"; + } + else { + return $return_error; + } +} + +# sup_quota_inter test si la valeur saisi dans le soft level est bien supérieur à celle du warning level ou équivalente +# dans le cas d'une valeur à zéro ou bien d'un unlimited +######################################################################################################################### +# sup_quota_inter is use to test if the value of the soft level is superior to the value of the warning level or the same +# in case of an 'unlimited' or a value at 0. + +sub sup_quota_inter { + + my ($fm, $softlvl) = @_; + my $self = shift; + my $return_error = $self->localise('SOFT_INF_WARN'); + my $cgi = $self->{cgi}; + my $warnlvl = $cgi->param('Warnlvl'); + + if (!$softlvl && !$warnlvl){ + return "OK"; + } + elsif ($softlvl eq 'unlimited' && $warnlvl eq 'unlimited'){ + return "OK"; + } + elsif ($softlvl == '0' && $warnlvl == '0'){ + return "OK"; + } + elsif ($softlvl > $warnlvl){ + return "OK"; + } + else { + return $return_error; + } +} + +# sup_quota_inter test si la valeur saisi dans le hard level est bien supérieur à celle du soft level ou équivalente +# dans le cas d'une valeur à zéro ou bien d'un unlimited +####################################################################################################################### +# sup_quota_inter is used to test if the value of the hard level is superior to the value of the soft level or the same +# in case of an 'unlimited' or a value at 0. + +sub sup_quota_hard { + + my ($fm, $hardlvl) = @_; + my $self = shift; + my $return_error = $self->localise('HARD_INF_OTHER'); + my $cgi = $self->{cgi}; + my $warnlvl = $cgi->param('Warnlvl'); + my $softlvl = $cgi->param('Softlvl'); + + if (!$softlvl && !$hardlvl){ + return "OK"; + } + elsif ($softlvl eq 'unlimited' && $warnlvl eq 'unlimited') { + return "OK"; + } + elsif ($softlvl == '0' && $hardlvl == '0'){ + return "OK"; + } + elsif ($hardlvl > $softlvl){ + return "OK"; + } + else { + return $return_error; + } +} + +# unique_username est utilisé pour vérifié si le nom d'utilisateur est bien unique dans le cas d'une création d'utilisateur +################################################################################################################################ +# unique_username is used to verify if the username in the username's field is already taken or notin case of an user's creation + +sub unique_username { + + my ($fm, $user_get) = @_; + my $self = shift; + my $return_error = $self->localise('MULTIPLE_USERNAME'); + my $present = 0; + open(USER, "zarafa-admin -l | awk 'NR > 4' |"); + while(){ + my $user = $_; + if ($user =~ m/$user_get\t/){ + $present = 1; + } + } + close(USER); + if($present == 1){ + return $return_error; + } + else { + return "OK"; + } +} + +# unique_email est utilisé pour vérifié si l'email de l'utilisateur est bien unique dans le cas d'une création d'utilisateur +############################################################################################################################ +# unique_email is used to verify if the email in the email's field is already taken or not in case of an user's creation + +sub unique_email { + + my ($fm, $email_get) = @_; + my $self = shift; + my $return_error = $self->localise('MULTIPLE_EMAIL'); + my $cgi = $self->{cgi}; + my $present = 0; + open(USER, "zarafa-admin -l | awk 'NR > 3' |"); + while(){ + my $user = $_; + $user =~ s/\t{2}.*$//g; + $user =~ s/^\t{1}//g; + chomp $user; + if($user) { + if ($user =~ /^([-\@\w.]+)$/) { + $user = $1; # $data now untainted + } + else { + die "Bad data in '$user'"; + } + open(EMAIL, "zarafa-admin --details \"$user\" |"); + while(){ + my $ligne = $_; + if ($ligne =~ m/$email_get/){ + $present = 1; + } + } + } + close(EMAIL); + } + close(USER); + if($present == 1){ + return $return_error; + } + else { + return "OK"; + } +} + +# unique_username_modify est utilisé pour vérifié si le nom d'utilisateur est bien unique dans le cas d'une modification +######################################################################################################################################### +# unique_username_modify is used to verify if the username in the username's field is already taken or not in case of user's modification + +sub unique_username_modify { + + my ($fm, $user_get) = @_; + my $self = shift; + my $return_error = $self->localise('MULTIPLE_USERNAME'); + my $cgi = $self->{cgi}; + my $param_user = $cgi->param('actUsr'); + my $present = 0; + + if($user_get eq $param_user){ + return "OK"; + } + else { + open(USER, "zarafa-admin -l | awk 'NR > 4' |"); + while(){ + my $user = $_; + if ($user =~ m/$user_get\t/){ + $present = 1; + } + } + close(USER); + if($present == 1){ + return $return_error; + } + else { + return "OK"; + } + } +} + +# unique_email_modify est utilisé pour vérifié si l'email utilisateur est bien unique dans le cas d'une modification +################################################################################################################################ +# unique_email_modify is used to verify if the email in the email's field is already taken or not in case of user's modification + +sub unique_email_modify { + + my ($fm, $email_get) = @_; + my $self = shift; + my $return_error = $self->localise('MULTIPLE_EMAIL'); + my $cgi = $self->{cgi}; + my $param_user = $cgi->param('actUsr'); + my $present = 0; + + open(MAIL, "zarafa-admin --details \"$param_user\" |"); + while(){ + my $ligne = $_; + if ($ligne =~ m/$email_get/){ + return "OK"; + } + } + close(MAIL); + + open(USER, "zarafa-admin -l | awk 'NR > 3' |"); + while(){ + my $user = $_; + $user =~ s/\t{2}.*$//g; + $user =~ s/^\t{1}//g; + chomp $user; + if($user) { + if ($user =~ /^([-\@\w.]+)$/) { + $user = $1; # $data now untainted + } + else { + die "Bad data in '$user'"; + } + open(EMAIL, "zarafa-admin --details \"$user\" |"); + while(){ + my $mail = $_; + if ($mail =~ m/$email_get/){ + $present = 1; + } + } + } + close(EMAIL); + } + close(USER); + + if($present == 1){ + return $return_error; + } + else { + return "OK"; + } +} + +# unique_groupname est utilisé pour vérifié si le nom du groupe est bien unique dans le cas d'une création de groupe +#################################################################################################################### +# unique_groupname is used to verify if the groupnamed is already taken or not in case of an group's creation + +sub unique_groupname { + + my ($fm, $groupname) = @_; + my $self = shift; + my $return_error = $self->localise('MULTIPLE_GROUPNAME'); + my $present = 0; + + open(GROUP, "zarafa-admin -L | awk 'NR > 3' |"); + while(){ + my $ligne = $_; + if ($ligne =~ m/$groupname/i){ + $present = 1; + } + } + close(GROUP); + + if($present == 1){ + return $return_error; + } + else { + return "OK"; + } +} + +# Cette fonction est principalement utilisé pour vérifié la composition d'un nom d'utilisateur saisi par l'utilisateur +###################################################################################################################### +# This function is mainly use to verify the composition of an username enter by an user. + +sub my_username { + + my ($fm, $username) = @_; + my $self = shift; + my $return_error = $self->localise('FALSE_USERNAME'); + + if ($username) { + if($username =~ m/^\w+((\.|\-|@)?\w+)*$/){ + return "OK"; + } + else { + return $return_error; + } + } + else { + return $return_error; + } +} + +sub show_company_users { + + my $self = shift; + my $q = $self->{cgi}; + + my $company = $q->param('actComp'); + if ($company =~ /^([-\@\w.]+)$/) { + $company = $1; # $data now untainted + } + else { + die "bad data in $company"; + } + my $scriptname = basename($0); + + # Localisation + # Localization + my $username = $self->localise('USER_NAME_ARRAY'); + my $suppr = $self->localise('DELETE'); + + # Affichage de l'en-tête du tableau + # Display the header + print " \n \n "; + print $q->start_table ({-CLASS => "sme-border"}),"\n "; + print $q->Tr( + esmith::cgi::genSmallCell($q, $username,"header"), + esmith::cgi::genSmallCell($q, $suppr,"header")); + + # Parcours de la liste des groupes avec affichage dans le tableau de chacun, création et affichage des liens correspondant + # Browse the group's list and display them into the array, create and diplay the links + open(LIRE, "zarafa-admin -l | cut -f2 |"); + my $user; + my $nbr = 0; + while () { + if (m/\w+\@$company/) { + $user = $_; + my $delete = "$suppr"; + my $modify = "$user"; + print $q->Tr( + esmith::cgi::genSmallCell($q,$modify ,"normal")," ", + esmith::cgi::genSmallCell($q,$delete,"normal")); + } + } + close(LIRE); + + print qq(\n); + + my $add_user = $self->localise('ADD_USER'); + my $add_user_bubble = $self->localise('ADD_USER_BUBBLE'); + + my $out ="

$add_user

"; + + +return $out; +} + +sub print_message { + + my ($fm, $word) = @_; + $word = $fm->localise($word); + print qq($word); + return undef; + +} + +sub create_company { + + my ($self) = @_; + my $cgi = $self->{cgi}; + + my $companyname = $self->{cgi}->param('createcompanyname'); + if ($companyname =~ /^([-\@\w.]+)$/) { + $companyname = $1; # $data now untainted + } + else { + die "Bad data in '$companyname'"; + } + + + system("zarafa-admin --create-company \"$companyname\" > /dev/null") == 0 + or die "Impossible de créer la companie $companyname"; + + $self->success('CREATE_COMPANY_SUCCESS'); + +} + +sub delete_company { + + my ($self) = @_; + my $cgi = $self->{cgi}; + + my $companyname = $self->{cgi}->param('actComp'); + if ($companyname =~ /^([-\@\w.]+)$/) { + $companyname = $1; # $data now untainted + } + else { + die "Bad data in '$companyname'"; + } + + system("zarafa-admin --delete-company \"$companyname\" > /dev/null") == 0 + or die "Impossible de créer la companie $companyname"; + + $self->success('DELETE_COMPANY_SUCCESS'); +} + +sub display_delete_comp_button { + + my ($self) = @_; + my $cgi = $self->{cgi}; + + my $group = $cgi->param('actComp'); + if ($group =~ /^([-\@\w.]+)$/) { + $group = $1; # $data now untainted + } + else { + die "Bad data in '$group'"; + } + + $self->print_button("DELETE"); + +} \ No newline at end of file