diff --git a/gosa-plugins/mail/personal/mail/class_mailAccount.inc b/gosa-plugins/mail/personal/mail/class_mailAccount.inc
index 2abcabb7cae8aadc6fe883785625a8fe009b7706..1d3993a1dca3468f42cd1e203e80e3ace9dc3d26 100644 (file)
*/
+/*
+
+ FLAG POSTNAME DESC
+ ####################################################################################################
+ L (!) only_local Enables: "User is only allowed to send and receive local mails"
+
+ <REVERSED> If checked in the ui, the flag is not present in the
+ gosaMailDeliveryMode attribute. If its unchecked in the ui, the
+ character 'L' is added to the delivery flags.
+
+ R use_mailsize_limit Enables rule: "Reject mails bigger than [n] MB";
+ S use_spam_filter Enables rule: "Move mails tagged with SPAM level greater than [n]
+ to folder [x]"
+ V use_vacation Enables: "Vacation message"
+ C own_script Enables: "Use custom sieve script (disables all Mail options!)"
+ I drop_own_mails Enables: "No delivery to own mailbox."
+
+*/
+
class mailAccount extends plugin
{
/* Definitions */
var $plHeadline = "Mail";
- var $plDescription = "This does something";
+ var $plDescription = "Manage personal mail settings";
var $view_logged = FALSE;
var $is_account = FALSE;
var $initially_was_account = FALSE;
/* Initialize configured values
*/
- if($this->is_account){
+ if($this->is_account && !$this->is_template){
if($this->mailMethod->connect() && $this->mailMethod->account_exists()){
if($this->mailMethod->domainSelectionEnabled()){
$this->mailDomainPart = preg_replace("/^[^@]*+@/","",$this->mail);
$this->mail = preg_replace("/@.*$/","\\1",$this->mail);
- if(!in_array($this->mailDomainPart,$this->mailDomainParts)){
+ if(!in_array_strict($this->mailDomainPart,$this->mailDomainParts)){
$this->mailDomainParts[] = $this->mailDomainPart;
}
}
$list = $this->mailAddressSelect->save();
foreach ($list as $entry){
$val = $entry['mail'][0];
- if (!in_array ($val, $this->gosaMailAlternateAddress) && $val != $this->mail){
+ if (!in_array_strict($val, $this->gosaMailAlternateAddress) && $val != $this->mail){
$this->addForwarder($val);
$this->is_modified= TRUE;
}
return($this->mailAddressSelect->execute());
}
- if (isset($_POST['add_forwarder'])){
- if ($_POST['forward_address'] != ""){
- $address= $_POST['forward_address'];
+ if (isset($_POST['add_forwarder']) && isset($_POST['forward_address'])){
+ if (!empty($_POST['forward_address'])){
+ $address= get_post('forward_address');
$valid= FALSE;
if (!tests::is_email($address)){
if (!tests::is_email($address, TRUE)){
}
}
} elseif ($address == $this->mail
- || in_array($address, $this->gosaMailAlternateAddress)) {
+ || in_array_strict($address, $this->gosaMailAlternateAddress)) {
msg_dialog::display(_("Error"),_("Cannot add primary address to the list of forwarders!") , ERROR_DIALOG);
} else {
$valid= TRUE;
}
}
}
- if (isset($_POST['delete_forwarder'])){
+ if (isset($_POST['delete_forwarder']) && isset($_POST['forwarder_list'])){
$this->delForwarder ($_POST['forwarder_list']);
}
if ($this->mailAddressSelect instanceOf mailAddressSelect){
} else {
$valid= TRUE;
}
- if ($valid && ($user= $this->addAlternate ($_POST['alternate_address'])) != ""){
+ if ($valid && ($user= $this->addAlternate (get_post('alternate_address'))) != ""){
$ui= get_userinfo();
$addon= "";
if ($user[0] == "!") {
$smarty->assign("$name"."ACL", $this->getacl($name));
}
foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
+ $smarty->assign($attr,set_post($this->$attr));
}
$smarty->assign("quotaEnabled", $this->mailMethod->quotaEnabled());
if($this->mailMethod->quotaEnabled()){
$smarty->assign("quotaUsage", mailMethod::quota_to_image($this->quotaUsage,$this->gosaMailQuota));
- $smarty->assign("gosaMailQuota",$this->gosaMailQuota);
+ $smarty->assign("gosaMailQuota",set_post($this->gosaMailQuota));
}
$smarty->assign("domainSelectionEnabled", $this->mailMethod->domainSelectionEnabled());
- $smarty->assign("MailDomains", $this->mailDomainParts);
- $smarty->assign("MailDomain" , $this->mailDomainPart);
- $smarty->assign("MailServers", $this->mailMethod->getMailServers());
+ $smarty->assign("MailDomains", set_post($this->mailDomainParts));
+ $smarty->assign("MailDomain" , set_post($this->mailDomainPart));
+ $smarty->assign("MailServers", set_post($this->mailMethod->getMailServers()));
$smarty->assign("allowSieveManagement", $this->mailMethod->allowSieveManagement());
$smarty->assign("own_script", $this->sieveManagementUsed);
/* _Multiple users vars_ */
foreach($this->attributes as $attr){
$u_attr = "use_".$attr;
- $smarty->assign($u_attr,in_array($attr,$this->multi_boxes));
+ $smarty->assign($u_attr,in_array_strict($attr,$this->multi_boxes));
}
foreach(array("only_local","gosaMailForwardingAddress","use_mailsize_limit","drop_own_mails","use_vacation","use_spam_filter") as $attr){
$u_attr = "use_".$attr;
- $smarty->assign($u_attr,in_array($attr,$this->multi_boxes));
+ $smarty->assign($u_attr,in_array_strict($attr,$this->multi_boxes));
}
$smarty->assign("template", "");
if (count($this->vacationTemplates)){
$smarty->assign("show_templates", "true");
- $smarty->assign("vacationtemplates", $this->vacationTemplates);
+ $smarty->assign("vacationtemplates", set_post($this->vacationTemplates));
if (isset($_POST['vacation_template'])){
- $smarty->assign("template", $_POST['vacation_template']);
+ $smarty->assign("template", set_post(get_post('vacation_template')));
}
} else {
$smarty->assign("show_templates", "false");
*/
$smarty->assign("spamlevel", $this->SpamLevels);
$smarty->assign("spambox" , $this->MailBoxes);
-
+ $smarty->assign("is_template", $this->is_template);
$smarty->assign("multiple_support",$this->multiple_support_active);
return($display.$smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
}
$server = $this->gosaMailServer;
plugin::save_object();
- if(!$this->mailMethod->isModifyableServer() && $this->initially_was_account){
+ if(!$this->mailMethod->isModifyableServer() && $this->initially_was_account && !$this->is_template){
$this->gosaMailServer = $server;
}
- if(!$this->mailMethod->isModifyableMail() && $this->initially_was_account){
+ if(!$this->mailMethod->isModifyableMail() && $this->initially_was_account && !$this->is_template){
$this->mail = $mail;
}else{
/* Get posted mail domain part, if necessary
*/
if($this->mailMethod->domainSelectionEnabled() && isset($_POST['MailDomain'])){
- if(in_array(get_post('MailDomain'), $this->mailDomainParts)){
+ if(in_array_strict(get_post('MailDomain'), $this->mailDomainParts)){
$this->mailDomainPart = get_post('MailDomain');
}
}
*/
if (isset($_POST["import_vacation"]) && isset($this->vacationTemplates[$_POST["vacation_template"]])){
if($this->multiple_support_active){
- $contents = ltrim(preg_replace("/^DESC:.*$/m","",file_get_contents($_POST["vacation_template"])));
+ $contents = ltrim(preg_replace("/^DESC:.*$/m","",file_get_contents(get_post("vacation_template"))));
}else{
- $contents = $this->prepare_vacation_template(file_get_contents($_POST["vacation_template"]));
+ $contents = $this->prepare_vacation_template(file_get_contents(get_post("vacation_template")));
}
$this->gosaVacationMessage= htmlspecialchars($contents);
}
if($this->mailMethod->vacationRangeEnabled()){
if($this->acl_is_writeable("gosaVacationMessage") && preg_match("/V/",$this->gosaMailDeliveryMode)){
if(isset($_POST['gosaVacationStart'])){
- $this->gosaVacationStart = $_POST['gosaVacationStart'];
+ $this->gosaVacationStart = get_post('gosaVacationStart');
}
if(isset($_POST['gosaVacationStop'])){
- $this->gosaVacationStop = $_POST['gosaVacationStop'];
+ $this->gosaVacationStop = get_post('gosaVacationStop');
}
}
}
}
return ($attrs["uid"][0]);
}
- if (!in_array($address, $this->gosaMailAlternateAddress)){
+ if (!in_array_strict($address, $this->gosaMailAlternateAddress)){
$this->gosaMailAlternateAddress[]= $address;
$this->is_modified= TRUE;
}
}
if ($this->is_template){
if (!tests::is_email($mail, TRUE)){
- $message[]= msgPool::invalid(_("Mail address"),"","","%givenName.%sn@your-domain.com");
+ $message[]= msgPool::invalid(_("Mail address"),"","","{%givenName}.{%sn}@your-domain.com");
}
} else {
if (!tests::is_email($mail)){
foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
- if (in_array($val, $skip)){
+ if (in_array_strict($val, $skip)){
continue;
}
$value= preg_replace ("/%$repl/i", $this->parent->$repl, $value);
}
}
+
+ // Remove non ASCII charcters
+ $value = iconv('UTF-8', 'US-ASCII//TRANSLIT', $value);
+ $value = preg_replace('/[^(\x20-\x7F)]*/','',$value);
+
+ // No spaces are allowed here
+ $value = preg_replace("/[ ]/","", $value);
array_push($this->$val, strtolower(rewrite($value)));
}
}
}
$this->mail= strtolower(rewrite($this->mail));
+ // Remove non ASCII charcters
+ $this->mail= iconv('UTF-8', 'US-ASCII//TRANSLIT', $this->mail);
+ $this->mail= preg_replace('/[^(\x20-\x7F)]*/','',$this->mail);
+
+ // No spaces are allowed here
+ $this->mail = preg_replace("/[ ]/","", $this->mail);
+
// Fix mail address when using templates
if($this->is_account && $this->mailMethod->domainSelectionEnabled()){
$this->mailDomainPart = preg_replace("/^[^@]*+@/","",$this->mail);
$this->mail = preg_replace("/@.*$/","\\1",$this->mail);
- if(!in_array($this->mailDomainPart,$this->mailDomainParts)){
+ if(!in_array_strict($this->mailDomainPart,$this->mailDomainParts)){
$this->mailDomainParts[] = $this->mailDomainPart;
}
}
/* Execute to save mailAlternateAddress && gosaMailForwardingAddress */
$this->execute();
if(isset($_POST['mail'])){
- $this->mail = $_POST['mail'];
+ $this->mail = get_post('mail');
}
}
if($this->mailMethod->domainSelectionEnabled()){
$this->mailDomainPart = preg_replace("/^[^@]*+@/","",$this->mail);
$this->mail = preg_replace("/@.*$/","\\1",$this->mail);
- if(!in_array($this->mailDomainPart,$this->mailDomainParts)){
+ if(!in_array_strict($this->mailDomainPart,$this->mailDomainParts)){
$this->mailDomainParts[] = $this->mailDomainPart;
}
}
function get_multi_edit_values()
{
$ret = plugin::get_multi_edit_values();
- if(in_array("gosaMailQuota",$this->multi_boxes)){
+ if(in_array_strict("gosaMailQuota",$this->multi_boxes)){
$ret['gosaMailQuota'] = $this->gosaMailQuota;
}
$flag_add = $flag_remove = array();
"C" => "own_script",
"I" => "drop_own_mails");
foreach($opts as $flag => $post){
- if(in_array($post, $this->multi_boxes)){
+ if(in_array_strict($post, $this->multi_boxes)){
if(preg_match("/".$flag."/",$tmp)){
$flag_add[] = $flag;
}else{
$ret['flag_remove'] = $flag_remove;
if($this->mailMethod->vacationRangeEnabled()){
- if(in_array("V",$flag_add)){
- $ret['gosaVacationStart'] = $this->gosaVacationStart = $_POST['gosaVacationStart'];
- $ret['gosaVacationStop'] = $this->gosaVacationStop = $_POST['gosaVacationStop'];
+ if(in_array_strict("V",$flag_add)){
+ $ret['gosaVacationStart'] = $this->gosaVacationStart = get_post('gosaVacationStart');
+ $ret['gosaVacationStop'] = $this->gosaVacationStop = get_post('gosaVacationStop');
}
}
return($ret);
{
$message = plugin::multiple_check();
- if(empty($this->gosaMailServer) && in_array("gosaMailServer",$this->multi_boxes)){
+ if(empty($this->gosaMailServer) && in_array_strict("gosaMailServer",$this->multi_boxes)){
$message[]= msgPool::noserver(_("Mail"));
}
/* Check quota */
- if ($this->gosaMailQuota != '' && in_array("gosaMailQuota",$this->multi_boxes)){
+ if ($this->gosaMailQuota != '' && in_array_strict("gosaMailQuota",$this->multi_boxes)){
if (!is_numeric($this->gosaMailQuota)) {
$message[]= msgPool::invalid(_("Quota size"),$this->gosaMailQuota,"/^[0-9]*/");
} else {
}
/* Check rejectsize for integer */
- if ($this->gosaMailMaxSize != '' && in_array("gosaMailMaxSize",$this->multi_boxes)){
+ if ($this->gosaMailMaxSize != '' && in_array_strict("gosaMailMaxSize",$this->multi_boxes)){
if (!is_numeric($this->gosaMailMaxSize)){
$message[]= msgPool::invalid(_("Mail reject size"),$this->gosaMailMaxSize,"/^[0-9]*/");
} else {
}
}
- if(empty($this->gosaSpamMailbox) && in_array("gosaSpamMailbox",$this->multi_boxes)){
+ if(empty($this->gosaSpamMailbox) && in_array_strict("gosaSpamMailbox",$this->multi_boxes)){
$message[]= msgPool::required(_("Spam folder"));
}
"plCategory" => array("users"),
"plOptions" => array(),
- "plRequirements"=> array('ldapSchema' => array('gosaMailAccount' => '>=2.7')),
+ "plRequirements"=> array(
+ 'ldapSchema' => array('gosaMailAccount' => '>=2.7'),
+ 'onFailureDisablePlugin' => array(get_class())
+ ),
"plProperties" =>
array(
"name" => "cyrusDeleteMailbox",
"type" => "bool",
"default" => 'true',
- "description" => _("The 'cyrusDeleteMailbox' statement determines if GOsa should remove the mailbox from your IMAP server or keep it after the account is deleted in LDAP."),
+ "description" => _("Remove mail boxes from the IMAP storage after they their user gets removed."),
"check" => "gosaProperty::isBool",
"migrate" => "",
"group" => "mail",
"name" => "cyrusAutocreateFolders",
"type" => "string",
"default" => "",
- "description" => _("The 'cyrusAutocreateFolders' statement contains a comma seperated list of personal IMAP folders that should be created along initial account creation."),
+ "description" => _("Comma separated list of folders to be automatically created on user creation."),
"check" => "gosaProperty::isString",
"migrate" => "",
"group" => "mail",
"gosaMailDeliveryModeV" => _("Add vacation information"), // This is flag of gosaMailDeliveryMode
"gosaVacationMessage" => _("Vacation message"),
- "gosaMailDeliveryModeS" => _("Use spam filter"), // This is flag of gosaMailDeliveryMode
- "gosaSpamSortLevel" => _("Spam level"),
- "gosaSpamMailbox" => _("Spam mail box"),
+ "gosaMailDeliveryModeS" => _("Use SPAM filter"), // This is flag of gosaMailDeliveryMode
+ "gosaSpamSortLevel" => _("SPAM level"),
+ "gosaSpamMailbox" => _("SPAM mail box"),
"sieveManagement" => _("Sieve management"),
- "gosaMailDeliveryModeR" => _("Reject due to mailsize"), // This is flag of gosaMailDeliveryMode
+ "gosaMailDeliveryModeR" => _("Reject due to mail size"), // This is flag of gosaMailDeliveryMode
"gosaMailMaxSize" => _("Mail max size"),
"gosaMailForwardingAddress" => _("Forwarding address"),