X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fpersonal%2Fconnectivity%2Fclass_kolabAccount.inc;h=9f08ea9110e4bdad8c1c550f80f08d79ec042c9e;hb=e7b70ce242b052c5e0d0dfd45dfac5e6f9f36ba3;hp=2b5ae71c864e4d6a8fca2f7367dc92493ea134f6;hpb=33ce29bacccb3c71756e148077440bdcfa6b08e1;p=gosa.git diff --git a/plugins/personal/connectivity/class_kolabAccount.inc b/plugins/personal/connectivity/class_kolabAccount.inc index 2b5ae71c8..9f08ea911 100644 --- a/plugins/personal/connectivity/class_kolabAccount.inc +++ b/plugins/personal/connectivity/class_kolabAccount.inc @@ -2,28 +2,24 @@ class kolabAccount extends plugin { /* Definitions */ - var $plHeadline= "Kolab"; - var $plDescription= "This does something"; - - /* CLI vars */ - var $cli_summary= "Manage users Kolab account"; - var $cli_description= "Some longer text\nfor help"; - var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); + var $plHeadline = "Kolab"; + var $plDescription = "This does something"; /* Kolab attributes */ - var $kolabInvitationPolicy= array(); - var $kolabFreeBusyFuture= 60; - var $unrestrictedMailSize= 0; - var $calFBURL= ""; - var $kolabDelegate= array(); + var $kolabInvitationPolicy = array(); + var $kolabFreeBusyFuture = 60; + var $unrestrictedMailSize = 0; + var $calFBURL = ""; + var $kolabDelegate = array(); /* attribute list for save action */ - var $attributes= array( "kolabFreeBusyFuture", "unrestrictedMailSize", "calFBURL"); - var $objectclasses= array("kolab"); + var $attributes = array("kolabFreeBusyFuture", "unrestrictedMailSize", "calFBURL","kolabDelegate"); + var $objectclasses = array("kolabInetOrgPerson"); /* Helper */ var $imapping= array(); + function kolabAccount ($config, $dn= NULL) { plugin::plugin ($config, $dn); @@ -31,9 +27,11 @@ class kolabAccount extends plugin /* Pull arrays */ foreach(array("kolabDelegate", "kolabInvitationPolicy") as $attr){ if (isset($this->attrs["$attr"]["count"])){ + $tmp = array(); for ($i= 0; $i<$this->attrs["$attr"]["count"]; $i++){ - array_push($this->$attr, $this->attrs["$attr"][$i]); + $tmp[]=$this->attrs["$attr"][$i]; } + $this->$attr = $tmp; } } @@ -42,12 +40,23 @@ class kolabAccount extends plugin $this->kolabInvitationPolicy= array("ACT_MANUAL"); } + /* Check is account state */ + $this->is_account = false; + if(count($this->kolabDelegate)){ + $this->is_account = true; + } + foreach(array("calFBURL","unrestrictedMailSize") as $attr){ + if(!empty($this->$attr)){ + $this->is_account = true; + } + } } + function execute() { /* Call parent execute */ -// plugin::execute(); + plugin::execute(); /* Show tab dialog headers */ $display= ""; @@ -60,6 +69,7 @@ class kolabAccount extends plugin $smarty->assign("$val", $this->$val); $smarty->assign($val."ACL", chkacl($this->acl, "$val")); } + $smarty->assign("kolabAccountACL", chkacl($this->acl, "kolabAccountACL")); /* Check for invitation action */ $nr= 0; @@ -82,9 +92,6 @@ class kolabAccount extends plugin /* Unify addresses */ $new= array(); foreach($this->kolabInvitationPolicy as $value){ - if (preg_match('/^:/', $value)){ - continue; - } $address= preg_replace('/^([^:]+:).*$/', '\1', $value); $new[$address]= $value; } @@ -153,9 +160,11 @@ class kolabAccount extends plugin /* Transfer account states for this union */ if (isset($this->parent) && $this->parent->by_object['mailAccount']->is_account){ - $smarty->assign('is_account', 'true'); - } else { - $smarty->assign('is_account', ''); + $smarty->assign('mail_account', 'true'); + } elseif($this-> initially_was_account && (isset($this->attrs['objectClass']) && (in_array("kolabInetOrgPerson",$this->attrs['objectClass'])))){ + $smarty->assign('mail_account', 'true'); + }else{ + $smarty->assign('mail_account', ''); } /* Transfer delegation list */ @@ -172,8 +181,19 @@ class kolabAccount extends plugin $this->imapping= array(); $nr= 0; $acl= chkacl($this->acl, "kolabInvitationPolicy"); + $changeState = ""; foreach ($this->kolabInvitationPolicy as $entry){ + + $changeState .= "changeState('address".$nr."'); \n changeState('policy".$nr."'); \n + changeState('add".$nr."'); \n changeState('remove".$nr."'); \n"; + $invitation.= ""; + if($this->is_account){ + $dis = " "; + }else{ + $dis = " disabled "; + } + /* The default entry does not have colons... */ if (!preg_match('/:/', $entry)){ @@ -183,12 +203,12 @@ class kolabAccount extends plugin } else { $name= preg_replace('/:.*$/', '', $entry); $mode= preg_replace('/^[^:]*: */', '', $entry); - $invitation.= ""; + $invitation.= ""; } $invitation.= ""; /* Add mode switch */ - $invitation.= ""; foreach($policies as $key => $value){ if ($key == $mode){ $invitation.= ""; @@ -200,10 +220,10 @@ class kolabAccount extends plugin /* Assign buttons */ $button= ""; if ($nr == count($this->kolabInvitationPolicy)-1){ - $button= ""; + $button= ""; } if ($nr != 0) { - $button.= ""; + $button.= ""; } $invitation.= " $button\n"; @@ -211,21 +231,37 @@ class kolabAccount extends plugin $nr++; } $smarty->assign("invitation", $invitation); - + $smarty->assign("changeState", $changeState); + $smarty->assign("kolabState",$this->is_account); $display.= $smarty->fetch (get_template_path('kolab.tpl', TRUE, dirname(__FILE__))); + + return ($display); } function remove_from_parent() { /* Optionally execute a command after we're done */ + plugin::remove_from_parent(); + + if(!in_array("kolabInetOrgPerson",$this->attrs['objectClass'])){ + $this->attrs['objectClass'][] = "kolabInetOrgPerson"; + } + + $ldap = $this->config->get_ldap_linK(); + $ldap->cd($this->config->current['BASE']); + $ldap->cd ($this->dn); + $ldap->modify($this->attrs); + $this->handle_post_events('remove'); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/kolab account with dn '%s' failed."),$this->dn)); } function check() { - $message= array(); + /* Call common method to give check the hook */ + $message= plugin::check(); /* FBFuture is in days... */ if ($this->kolabFreeBusyFuture != "" && !preg_match('/^[0-9]+$/', $this->kolabFreeBusyFuture)){ @@ -271,6 +307,13 @@ class kolabAccount extends plugin { /* Do we need to flip is_account state? */ if (isset($_POST['connectivityTab'])){ + + if(isset($_POST["kolabState"])){ + $this->is_account = true; + }else{ + $this->is_account = false; + } + if (chkacl('unrestrictedMailSize', $this->acl == "")){ if (isset($_POST['unrestrictedMailSize']) && $_POST['unrestrictedMailSize'] == 1){ $this->unrestrictedMailSize= 1; @@ -315,13 +358,20 @@ class kolabAccount extends plugin $this->attrs['kolabDelegate']= $this->kolabDelegate; $this->attrs['kolabInvitationPolicy']= $this->kolabInvitationPolicy; + /* unrestrictedMailSize is boolean */ + if($this->attrs['unrestrictedMailSize']){ + $this->attrs['unrestrictedMailSize'] = "TRUE"; + }else{ + $this->attrs['unrestrictedMailSize'] = "FALSE"; + } + /* Write back to ldap */ $ldap= $this->config->get_ldap_link(); $ldap->cd($this->dn); $this->cleanup(); -$ldap->modify ($this->attrs); + $ldap->modify ($this->attrs); - show_ldap_error($ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/kolab account with dn '%s' failed."),$this->dn)); /* Optionally execute a command after we're done */ if ($this->initially_was_account == $this->is_account){ @@ -351,6 +401,19 @@ $ldap->modify ($this->attrs); $this->is_modified= TRUE; } + + /* Return plugin informations for acl handling */ + function plInfo() + { + return (array( + "plDescription" => _("Koalb account settings"), + "plSelfModify" => TRUE, + "plDepends" => array("objectClass" => "gosaAccount"), + "kolabFreeBusyFuture" => _("Free busy future"), + "unrestrictedMailSize" => _("Mail size restriction"), + "calFBURL" => _("Free busy information"), + "kolabDelegate" => _("Delegations"))); + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: