From 0da117e82b43c8a76ca6b4c5f631e51d02979d9c Mon Sep 17 00:00:00 2001 From: cajus Date: Fri, 13 May 2005 11:48:02 +0000 Subject: [PATCH] Updated kolab account to handle invitiation policies in a proper way git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@204 594d385d-05f5-0310-b6e9-bd551577e9d8 --- TODO | 4 + .../connectivity/class_kolabAccount.inc | 78 +++++++++++++++++-- plugins/personal/posix/class_posixAccount.inc | 2 +- 3 files changed, 77 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index 2f10b65fc..32db0aa39 100644 --- a/TODO +++ b/TODO @@ -13,6 +13,10 @@ Things to fix in 2.3.9: * Make it "barrierefrei" +* Unify filters (User -> Add local) + +* Check for iconv support in setup + Target for 2.4: =============== diff --git a/plugins/personal/connectivity/class_kolabAccount.inc b/plugins/personal/connectivity/class_kolabAccount.inc index 0bff3f326..a7a609a5a 100644 --- a/plugins/personal/connectivity/class_kolabAccount.inc +++ b/plugins/personal/connectivity/class_kolabAccount.inc @@ -21,6 +21,9 @@ class kolabAccount extends plugin var $attributes= array( "kolabFreeBusyFuture", "unrestrictedMailSize", "calFBURL"); var $objectclasses= array(); + /* Helper */ + var $imapping= array(); + function kolabAccount ($config, $dn= NULL) { plugin::plugin ($config, $dn); @@ -55,6 +58,38 @@ class kolabAccount extends plugin $smarty->assign($val."ACL", chkacl($this->acl, "$val")); } + /* Check for invitation action */ + $nr= 0; + while (isset($_POST["policy$nr"])){ + if (isset($_POST["add$nr"])){ + $this->kolabInvitationPolicy[]= ": ACT_MANUAL"; + } + if (isset($_POST["remove$nr"])){ + $new= array(); + foreach ($this->kolabInvitationPolicy as $entry){ + if (!preg_match("/^".$this->imapping[$nr].":/", $entry)){ + $new[]= $entry; + } + } + $this->kolabInvitationPolicy= $new; + } + $nr++; + } + + /* Unify addresses */ + $new= array(); + foreach($this->kolabInvitationPolicy as $value){ + if (preg_match('/^:/', $value)){ + continue; + } + $address= preg_replace('/^([^:]+:).*$/', '\1', $value); + $new[$address]= $value; + } + $this->kolabInvitationPolicy= array(); + foreach($new as $value){ + $this->kolabInvitationPolicy[]= $value; + } + /* Add delegation */ if (isset($_POST['add_delegation'])){ if ($_POST['delegate_address'] != ""){ @@ -125,6 +160,7 @@ class kolabAccount extends plugin /* Create InvitationPolicy table */ $invitation= ""; + $this->imapping= array(); $nr= 0; $acl= chkacl($this->acl, "kolabInvitationPolicy"); foreach ($this->kolabInvitationPolicy as $entry){ @@ -133,11 +169,12 @@ class kolabAccount extends plugin /* The default entry does not have colons... */ if (!preg_match('/:/', $entry)){ $invitation.= _("Anonymous"); + $name= ""; $mode= $entry; } else { $name= preg_replace('/:.*$/', '', $entry); - $mode= preg_replace('/^[^:]+: */', '', $entry); - $invitation.= ""; + $mode= preg_replace('/^[^:]*: */', '', $entry); + $invitation.= ""; } $invitation.= ""; @@ -154,12 +191,14 @@ class kolabAccount extends plugin /* Assign buttons */ $button= ""; if ($nr == count($this->kolabInvitationPolicy)-1){ - $button= "[Add button]"; - } elseif ($nr != 0) { - $button= "[Remove button]"; + $button= ""; + } + if ($nr != 0) { + $button.= ""; } $invitation.= " $button\n"; + $this->imapping[$nr]= $name; $nr++; } $smarty->assign("invitation", $invitation); @@ -189,6 +228,32 @@ class kolabAccount extends plugin $message[]= _("The value specified as Free Busy Information URL is invalid."); } + /* Check invitation policy for existing mail addresses */ + foreach($this->kolabInvitationPolicy as $policy){ + + /* Ignore anonymous string */ + if (!preg_match('/:/', $policy)){ + continue; + } + + $address= preg_replace('/^([^:]+).*$/', '\1', $policy); + if (!is_email($address)){ + if (!is_email($address, TRUE)){ + $message[]= sprintf(_("The invitation policy entry for address '%s' is not valid."), $address); + } + } else { + + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); + $ldap->search('(mail='.$address.')'); + if ($ldap->count() == 0){ + $message[]= sprintf(_("There's no mail user with address '%s' for your invitation policy!"), $address); + } else { + $valid= TRUE; + } + } + } + return ($message); } @@ -231,8 +296,9 @@ class kolabAccount extends plugin { plugin::save(); - /* Transfer delegation array */ + /* Transfer arrays */ $this->attrs['kolabDelegate']= $this->kolabDelegate; + $this->attrs['kolabInvitationPolicy']= $this->kolabInvitationPolicy; /* Write back to ldap */ $ldap= $this->config->get_ldap_link(); diff --git a/plugins/personal/posix/class_posixAccount.inc b/plugins/personal/posix/class_posixAccount.inc index f6616018b..47b7b36ad 100644 --- a/plugins/personal/posix/class_posixAccount.inc +++ b/plugins/personal/posix/class_posixAccount.inc @@ -751,7 +751,7 @@ class posixAccount extends plugin $ldap->search("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))", array("cn")); /* Create group if it doesn't exist */ - if (!$ldap->count()){ + if ($ldap->count() == 0){ $groupdn= preg_replace ('/^'.$this->config->current['DNMODE'].'=[^,]+,'.get_people_ou().'/i', 'cn='.$this->uid.','.get_groups_ou(), $this->dn); $g= new group($this->config, $groupdn); -- 2.30.2