Code

Fixed undefined index
[gosa.git] / plugins / personal / connectivity / class_kolabAccount.inc
index a889eb0a4be2a48496ba1fd22e8582d14dbabf0f..874220e71a0a189e79a2e93e628db294bcb8129e 100644 (file)
@@ -18,7 +18,8 @@ class kolabAccount extends plugin
 
   /* Helper */
   var $imapping= array();
-
+  var $mail_Account   = false;
+  var $ReadOnly = false;
 
   function kolabAccount ($config, $dn= NULL)
   {
@@ -50,6 +51,13 @@ class kolabAccount extends plugin
         $this->is_account = true;
       }
     } 
+
+    /* Transfer account states for this union */
+    if (isset($this->parent) && $this->parent->by_object['mailAccount']->is_account){
+      $this->mail_Account = true;
+    } elseif($this-> initially_was_account && (isset($this->attrs['objectClass']) && (in_array("kolabInetOrgPerson",$this->attrs['objectClass'])))){
+      $this->mail_Account = true;
+    }
   }
 
 
@@ -67,9 +75,22 @@ class kolabAccount extends plugin
     /* Load attributes */
     foreach($this->attributes as $val){
       $smarty->assign("$val", $this->$val);
-      $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
     }
-    $smarty->assign("kolabAccountACL", chkacl($this->acl, "kolabAccountACL"));
+
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $acl => $description){
+      $smarty->assign($acl."ACL",$this->getacl($acl,$this->ReadOnly));
+      $smarty->assign($acl."_W", $this->acl_is_writeable($acl,$this->ReadOnly));
+    }
+    $smarty->assign("is_account" ,  $this->is_account); 
+
+    if($this->ReadOnly){
+      $smarty->assign("is_removeable",false); 
+      $smarty->assign("is_createable",false); 
+    }else{
+      $smarty->assign("is_removeable",$this->acl_is_removeable()); 
+      $smarty->assign("is_createable",$this->acl_is_createable()); 
+    }
 
     /* Check for invitation action */
     $nr= 0;
@@ -125,7 +146,7 @@ class kolabAccount extends plugin
 
         if ($valid){
           /* Add it */
-          if (chkacl ($this->acl, "kolabDelegate") == ""){
+          if ($this->acl_is_writeable("kolabDelegate")){
             $this->addDelegate ($address);
             $this->is_modified= TRUE;
           }
@@ -135,10 +156,8 @@ class kolabAccount extends plugin
     }
 
     /* Delete forward email addresses */
-    if (isset($_POST['delete_delegation'])){
-      if (count($_POST['delegate_list'])
-          && chkacl ($this->acl, "kolabDelegate") == ""){
-
+    if ((isset($_POST['delete_delegation'])) && (isset($_POST['delegate_list']))){
+      if (count($_POST['delegate_list']) && $this->acl_is_writeable("kolabDelegate")){
         $this->delDelegate ($_POST['delegate_list']);
       }
     }
@@ -158,15 +177,6 @@ class kolabAccount extends plugin
       $smarty->assign('unrestrictedMailSizeState', "");
     }
 
-    /* Transfer account states for this union */
-    if (isset($this->parent) && $this->parent->by_object['mailAccount']->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 */
     if (!count($this->kolabDelegate)){
       /* Smarty will produce <option value=""></option> and tidy don't like that, so tell smarty to create no option (array();)*/
@@ -174,26 +184,34 @@ class kolabAccount extends plugin
     } else {
       $smarty->assign("kolabDelegate", $this->kolabDelegate);
     }
-    $smarty->assign("kolabDelegateACL", chkacl($this->acl, $this->kolabDelegate));
+
+    $smarty->assign("mail_account",$this->mail_Account);
 
     /* Create InvitationPolicy table */
     $invitation= "";
     $this->imapping= array();
     $nr= 0;
-    $acl= chkacl($this->acl, "kolabInvitationPolicy");
-    $changeState = "";
+    $changeState  = "";
     foreach ($this->kolabInvitationPolicy as $entry){
 
-      $changeState .= "changeState('address".$nr."'); \n changeState('policy".$nr."'); \n
-                         changeState('add".$nr."'); \n changeState('remove".$nr."'); \n";
+      if($this->acl_is_writeable("kolabInvitationPolicy")){
+        $changeState .= "changeState('address".$nr."'); \n changeState('policy".$nr."'); \n
+          changeState('add".$nr."'); \n changeState('remove".$nr."'); \n";
+      }
 
-      $invitation.= "<tr><td>";
-      if($this->is_account){
-        $dis = " ";
-      }else{
+      if(!$this->acl_is_writeable("kolabInvitationPolicy")){
         $dis = " disabled ";
+      }else{
+        if($this->is_account){
+          $dis = " ";
+        }else{
+          $dis = " disabled ";
+        }
+      }
+      $invitation.= "<tr><td>";
+
+      if(!$this->acl_is_readable("kolabInvitationPolicy"))    {
       }
-    
 
       /* The default entry does not have colons... */
       if (!preg_match('/:/', $entry)){
@@ -203,6 +221,10 @@ class kolabAccount extends plugin
       } else {
         $name= preg_replace('/:.*$/', '', $entry);
         $mode= preg_replace('/^[^:]*: */', '', $entry);
+
+        if(!$this->acl_is_readable("kolabInvitationPolicy")){
+          $name='';
+        }
         $invitation.= "<input name=\"address$nr\" size=16 maxlength=60 $acl value=\"$name\" id='address".$nr."' ".$dis.">";
       }
       $invitation.= "</td>";
@@ -309,12 +331,16 @@ class kolabAccount extends plugin
     if (isset($_POST['connectivityTab'])){
 
       if(isset($_POST["kolabState"])){
-        $this->is_account = true;
+        if($this->acl_is_createable()){
+          $this->is_account = true;
+        }
       }else{
-        $this->is_account = false;
+        if($this->acl_is_removeable()){
+          $this->is_account = false;
+        }
       }
-
-      if (chkacl('unrestrictedMailSize', $this->acl == "")){
+      
+      if ($this->acl_is_writeable("unrestrictedMailSize")){
         if (isset($_POST['unrestrictedMailSize']) && $_POST['unrestrictedMailSize'] == 1){
           $this->unrestrictedMailSize= 1;
         } else {
@@ -326,25 +352,26 @@ class kolabAccount extends plugin
     plugin::save_object();
 
     /* Save changes done in invitation policies */
-    $nr= 0;
-    $this->kolabInvitationPolicy= array();
-    while (isset($_POST["policy$nr"])){
+    if($this->acl_is_writeable("kolabInvitationPolicy")){
+      $nr= 0;
+      $this->kolabInvitationPolicy= array();
+      while (isset($_POST["policy$nr"])){
+
+        /* Anonymous? */
+        if (!isset($_POST["address$nr"])){
+          $this->kolabInvitationPolicy[]= $_POST["policy$nr"];
+        } else {
+          $this->kolabInvitationPolicy[]= $_POST["address$nr"].": ".$_POST["policy$nr"];
+        }
 
-      /* Anonymous? */
-      if (!isset($_POST["address$nr"])){
-        $this->kolabInvitationPolicy[]= $_POST["policy$nr"];
-      } else {
-        $this->kolabInvitationPolicy[]= $_POST["address$nr"].": ".$_POST["policy$nr"];
+        $nr++;
       }
-      
-      $nr++;
-    }
-    
-    /* If this one is empty, preset with ACT_MANUAL for anonymous users */
-    if (count ($this->kolabInvitationPolicy) == 0){
-      $this->kolabInvitationPolicy= array("ACT_MANUAL");
-    }
 
+      /* If this one is empty, preset with ACT_MANUAL for anonymous users */
+      if (count ($this->kolabInvitationPolicy) == 0){
+        $this->kolabInvitationPolicy= array("ACT_MANUAL");
+      }
+    }
   }
 
 
@@ -402,15 +429,26 @@ class kolabAccount extends plugin
   }
 
 
+  /* Return plugin informations for acl handling  */
   function plInfo()
   {
-    return (array(     "plDescription"   => _("Koalb account settings"),
+    return (array(     
+          "plShortName"     => _("Kolab"),
+          "plDescription"   => _("Kolab account settings"),
           "plSelfModify"    => TRUE,
-          "plDepends"       => array("objectClass" => "gosaAccount"),
-          "kolabFreeBusyFuture"   => _("Free busy future"),
-          "unrestrictedMailSize"  => _("Mail size restriction"),
-          "calFBURL"              => _("Free busy information"),
-          "kolabDelegate"         => _("Delegations")));
+          "plDepends"       => array("user"),
+          "plPriority"      => 2,                                 // Position in tabs
+          "plSection"       => "personal",                        // This belongs to personal
+          "plCategory"      => array("users"),
+          "plOptions"       => array(),
+
+          "plProvidedAcls"  => array(
+            "kolabFreeBusyFuture"   => _("Free busy future"),
+            "unrestrictedMailSize"  => _("Mail size restriction"),
+            "calFBURL"              => _("Free busy information"),
+            "kolabDelegate"         => _("Delegations"),
+            "kolabInvitationPolicy" => _("Invitation policy"))
+          ));
   }
 }