diff --git a/include/class_acl.inc b/include/class_acl.inc
index df6712ccfd0c5f9214459dfa55124c00b1136ad9..47c3916cc8574efe7c1c67d098ad6e77af8ff684 100644
--- a/include/class_acl.inc
+++ b/include/class_acl.inc
@@ -1,5 +1,4 @@
 <?php
-
 /*
   This code is part of FusionDirectory (http://www.fusiondirectory.org/)
   Copyright (C) 2003-2010  Cajus Pollmeier
@@ -99,9 +98,9 @@ class acl extends plugin
     while ($attrs = $ldap->fetch()) {
       // Allow objects without cn to be listed without causing an error.
       if (!isset($attrs['cn'][0]) && isset($attrs['uid'][0])) {
-        $this->users['U:'.$attrs['dn']] =  $attrs['uid'][0];
+        $this->users['U:'.$attrs['dn']] = $attrs['uid'][0];
       } elseif (!isset($attrs['uid'][0]) && isset($attrs['cn'][0])) {
-        $this->users['U:'.$attrs['dn']] =  $attrs['cn'][0];
+        $this->users['U:'.$attrs['dn']] = $attrs['cn'][0];
       } elseif (!isset($attrs['uid'][0]) && !isset($attrs['cn'][0])) {
         $this->users['U:'.$attrs['dn']] = $attrs['dn'];
       } else {
@@ -126,21 +125,22 @@ class acl extends plugin
     /* Roles */
     $ldap->cd($config->current['BASE']);
     $ldap->search('(objectClass=gosaRole)', array('cn', 'description','gosaAclTemplate','dn'));
-    while ($attrs= $ldap->fetch()) {
-      $dsc= "";
-      if (isset($attrs['description'][0])){
-        $dsc= $attrs['description'][0];
+    while ($attrs = $ldap->fetch()) {
+      $dsc = "";
+      if (isset($attrs['description'][0])) {
+        $dsc = $attrs['description'][0];
       }
 
       $role_id = $attrs['dn'];
 
-      $this->roles[$role_id]['acls'] =array();
-      for ($i= 0; $i < $attrs['gosaAclTemplate']['count']; $i++){
-        $acl= $attrs['gosaAclTemplate'][$i];
-        $this->roles[$role_id]['acls'] = array_merge($this->roles[$role_id]['acls'],acl::explodeACL($acl));
+      $this->roles[$role_id]['acls'] = array();
+      for ($i = 0; $i < $attrs['gosaAclTemplate']['count']; $i++) {
+        $acl = $attrs['gosaAclTemplate'][$i];
+
+        $this->roles[$role_id]['acls'] = array_merge($this->roles[$role_id]['acls'], acl::explodeACL($acl));
       }
       $this->roles[$role_id]['description'] = $dsc;
-      $this->roles[$role_id]['cn'] = $attrs['cn'][0];
+      $this->roles[$role_id]['cn']          = $attrs['cn'][0];
     }
 
     /* Objects */
@@ -188,23 +188,23 @@ class acl extends plugin
     }
 
     /* Fill acl types */
-    if ($this->isContainer){
-      $this->aclTypes= array("reset" => _("Reset ACLs"),
-                             "one" => _("One level"),
-                             "base" => _("Current object"),
-                             "sub" => _("Complete subtree"),
-                             "psub" => _("Complete subtree (permanent)"),
-                             "role" => _("Use ACL defined in role"));
+    if ($this->isContainer) {
+      $this->aclTypes = array("reset" => _("Reset ACLs"),
+                              "one"   => _("One level"),
+                              "base"  => _("Current object"),
+                              "sub"   => _("Complete subtree"),
+                              "psub"  => _("Complete subtree (permanent)"),
+                              "role"  => _("Use ACL defined in role"));
     } else {
-      $this->aclTypes= array("base" => _("Current object"),
+      $this->aclTypes = array("base" => _("Current object"),
           "role" => _("Use ACL defined in role"));
     }
     asort($this->aclTypes);
-    $this->targets= array("user" => _("Users"), "group" => _("Groups"));
+    $this->targets = array("user" => _("Users"), "group" => _("Groups"));
     asort($this->targets);
 
     /* Finally - we want to get saved... */
-    $this->is_account= TRUE;
+    $this->is_account = TRUE;
   }
 
   /*!
@@ -215,40 +215,41 @@ class acl extends plugin
     /* Call parent execute */
     plugin::execute();
 
-    $tmp= session::global_get('plist');
-    $plist= $tmp->info;
+    $tmp    = session::global_get('plist');
+    $plist  = $tmp->info;
 
     /* Handle posts */
-    if (isset($_POST['new_acl'])){
-      $this->dialogState= 'create';
-      $this->dialog= TRUE;
-      $this->currentIndex= count($this->gosaAclEntry);
+    if (isset($_POST['new_acl'])) {
+      $this->dialogState  = 'create';
+      $this->dialog       = TRUE;
+      $this->currentIndex = count($this->gosaAclEntry);
       $this->loadAclEntry(TRUE);
     }
 
-    $new_acl= array();
-    $aclDialog= FALSE;
-    $firstedit= FALSE;
+    $new_acl    = array();
+    $aclDialog  = FALSE;
+    $firstedit  = FALSE;
 
     /* Act on HTML post and gets here.
      */
-    if(isset($_GET['id']) && isset($_GET['act']) && $_GET['act'] == "edit"){
+    if (isset($_GET['id']) && isset($_GET['act']) && $_GET['act'] == "edit") {
       $id = trim($_GET['id']);
-      $this->dialogState= 'create';
-      $firstedit= TRUE;
-      $this->dialog= TRUE;
-      $this->currentIndex= $id;
+
+      $this->dialogState  = 'create';
+      $firstedit          = TRUE;
+      $this->dialog       = TRUE;
+      $this->currentIndex = $id;
       $this->loadAclEntry();
     }
 
-    foreach($_POST as $name => $post){
+    foreach ($_POST as $name => $post) {
 
       /* Actions... */
-      if (preg_match('/^acl_edit_.*_x/', $name)){
-        $this->dialogState= 'create';
-        $firstedit= TRUE;
-        $this->dialog= TRUE;
-        $this->currentIndex= preg_replace('/^acl_edit_([0-9]+).*$/', '\1', $name);
+      if (preg_match('/^acl_edit_.*_x/', $name)) {
+        $this->dialogState  = 'create';
+        $firstedit          = TRUE;
+        $this->dialog       = TRUE;
+        $this->currentIndex = preg_replace('/^acl_edit_([0-9]+).*$/', '\1', $name);
         $this->loadAclEntry();
         continue;
       }
@@ -265,16 +266,16 @@ class acl extends plugin
       }
 
       /* Only handle posts, if we allowed to modify ACLs */
-      if(!$this->acl_is_writeable("")){
+      if (!$this->acl_is_writeable("")) {
         continue;
       }
 
-      if (preg_match('/^acl_del_.*_x/', $name)){
+      if (preg_match('/^acl_del_.*_x/', $name)) {
         unset($this->gosaAclEntry[preg_replace('/^acl_del_([0-9]+).*$/', '\1', $name)]);
         continue;
       }
 
-      if (preg_match('/^cat_del_.*_x/', $name)){
+      if (preg_match('/^cat_del_.*_x/', $name)) {
         $idx = preg_replace('/^cat_del_([^_]+)_.*$/', '\1', $name);
         foreach ($this->config->data['CATEGORIES'][$idx]['classes'] as $key) {
           unset($this->aclContents["$idx/$key"]);
@@ -283,21 +284,23 @@ class acl extends plugin
       }
 
       /* Sorting... */
-      if (preg_match('/^sortup_.*_x/', $name)){
-        $index= preg_replace('/^sortup_([0-9]+).*$/', '\1', $name);
-        if ($index > 0){
-          $tmp= $this->gosaAclEntry[$index];
-          $this->gosaAclEntry[$index]= $this->gosaAclEntry[$index-1];
-          $this->gosaAclEntry[$index-1]= $tmp;
+      if (preg_match('/^sortup_.*_x/', $name)) {
+        $index = preg_replace('/^sortup_([0-9]+).*$/', '\1', $name);
+        if ($index > 0) {
+          $tmp = $this->gosaAclEntry[$index];
+
+          $this->gosaAclEntry[$index]     = $this->gosaAclEntry[$index - 1];
+          $this->gosaAclEntry[$index - 1] = $tmp;
         }
         continue;
       }
-      if (preg_match('/^sortdown_.*_x/', $name)){
-        $index= preg_replace('/^sortdown_([0-9]+).*$/', '\1', $name);
-        if ($index < count($this->gosaAclEntry)-1){
-          $tmp= $this->gosaAclEntry[$index];
-          $this->gosaAclEntry[$index]= $this->gosaAclEntry[$index+1];
-          $this->gosaAclEntry[$index+1]= $tmp;
+      if (preg_match('/^sortdown_.*_x/', $name)) {
+        $index = preg_replace('/^sortdown_([0-9]+).*$/', '\1', $name);
+        if ($index < count($this->gosaAclEntry) - 1) {
+          $tmp = $this->gosaAclEntry[$index];
+
+          $this->gosaAclEntry[$index]     = $this->gosaAclEntry[$index + 1];
+          $this->gosaAclEntry[$index + 1] = $tmp;
         }
         continue;
       }
@@ -314,25 +317,25 @@ class acl extends plugin
         }
 
         /* Ordinary ACLs */
-        if (!isset($new_acl[$object])){
-          $new_acl[$object]= array();
+        if (!isset($new_acl[$object])) {
+          $new_acl[$object] = array();
         }
-        if (isset($new_acl[$object][$attribute])){
-          $new_acl[$object][$attribute].= $value;
+        if (isset($new_acl[$object][$attribute])) {
+          $new_acl[$object][$attribute] .= $value;
         } else {
-          $new_acl[$object][$attribute]= $value;
+          $new_acl[$object][$attribute] = $value;
         }
       }
 
       // Remember the selected ACL role.
-      if(isset($_POST['selected_role']) && $_POST['aclType'] == 'role'){
+      if (isset($_POST['selected_role']) && $_POST['aclType'] == 'role') {
         $this->aclContents = "";
         $this->aclContents = base64_decode($_POST['selected_role']);
       }
     }
 
-    if(isset($_POST['acl_dummy_0_0_0'])){
-      $aclDialog= TRUE;
+    if (isset($_POST['acl_dummy_0_0_0'])) {
+      $aclDialog = TRUE;
     }
 
     if ($this->acl_is_writeable("")) {
@@ -342,59 +345,60 @@ class acl extends plugin
 
         foreach ($this->config->data['CATEGORIES'][$this->aclObject]['classes'] as $oc) {
 
-          if(isset($this->aclContents[$oc]) && is_array($this->aclContents)){
+          if (isset($this->aclContents[$oc]) && is_array($this->aclContents)) {
             unset($this->aclContents[$oc]);
-          }elseif(isset($this->aclContents[$this->aclObject.'/'.$oc]) && is_array($this->aclContents)){
+          } elseif (isset($this->aclContents[$this->aclObject.'/'.$oc]) && is_array($this->aclContents)) {
             unset($this->aclContents[$this->aclObject.'/'.$oc]);
-          }else{
-#          trigger_error("Huhm?");
+          } else {
+            //trigger_error("Huhm?");
           }
-          if (isset($new_acl[$oc]) && is_array($new_acl)){
-            $this->aclContents[$oc]= $new_acl[$oc];
+          if (isset($new_acl[$oc]) && is_array($new_acl)) {
+            $this->aclContents[$oc] = $new_acl[$oc];
           }
-          if (isset($new_acl[$this->aclObject.'/'.$oc]) && is_array($new_acl)){
-            $this->aclContents[$this->aclObject.'/'.$oc]= $new_acl[$this->aclObject.'/'.$oc];
+          if (isset($new_acl[$this->aclObject.'/'.$oc]) && is_array($new_acl)) {
+            $this->aclContents[$this->aclObject.'/'.$oc] = $new_acl[$this->aclObject.'/'.$oc];
           }
         }
       }
 
       /* Save new acl in case of base edit mode */
-      if ($this->aclType == 'base' && !$firstedit){
-        $this->aclContents= $new_acl;
+      if ($this->aclType == 'base' && !$firstedit) {
+        $this->aclContents = $new_acl;
       }
     }
 
     /* Cancel new acl? */
-    if (isset($_POST['cancel_new_acl'])){
-      $this->dialogState= 'head';
-      $this->dialog= FALSE;
-      if ($this->wasNewEntry){
-        unset ($this->gosaAclEntry[$this->currentIndex]);
+    if (isset($_POST['cancel_new_acl'])) {
+      $this->dialogState  = 'head';
+      $this->dialog       = FALSE;
+      if ($this->wasNewEntry) {
+        unset($this->gosaAclEntry[$this->currentIndex]);
       }
     }
 
     /* Save common values */
-    if($this->acl_is_writeable("")){
-      foreach (array("aclType","aclFilter", "aclObject", "target") as $key){
-        if (isset($_POST[$key])){
-          $this->$key= validate($_POST[$key]);
+    if ($this->acl_is_writeable("")) {
+      foreach (array("aclType","aclFilter", "aclObject", "target") as $key) {
+        if (isset($_POST[$key])) {
+          $this->$key = validate($_POST[$key]);
         }
       }
     }
 
     /* Store ACL in main object? */
-    if (isset($_POST['submit_new_acl'])){
-      $this->gosaAclEntry[$this->currentIndex]['type']= $this->aclType;
-      $this->gosaAclEntry[$this->currentIndex]['members']= $this->recipients;
-      $this->gosaAclEntry[$this->currentIndex]['acl']= $this->aclContents;
-      $this->gosaAclEntry[$this->currentIndex]['filter']= $this->aclFilter;
-      $this->dialogState= 'head';
-      $this->dialog= FALSE;
+    if (isset($_POST['submit_new_acl'])) {
+      $this->gosaAclEntry[$this->currentIndex]['type']    = $this->aclType;
+      $this->gosaAclEntry[$this->currentIndex]['members'] = $this->recipients;
+      $this->gosaAclEntry[$this->currentIndex]['acl']     = $this->aclContents;
+      $this->gosaAclEntry[$this->currentIndex]['filter']  = $this->aclFilter;
+
+      $this->dialogState  = 'head';
+      $this->dialog       = FALSE;
     }
 
     /* Cancel edit acl? */
-    if (isset($_POST['cancel_edit_acl'])){
-      $this->dialogState= 'create';
+    if (isset($_POST['cancel_edit_acl'])) {
+      $this->dialogState = 'create';
       foreach ($this->config->data['CATEGORIES'][$this->aclObject]['classes'] as $oc) {
         if (isset($this->savedAclContents[$oc])) {
           $this->aclContents[$oc] = $this->savedAclContents[$oc];
@@ -432,29 +436,31 @@ class acl extends plugin
     }
 
     /* Remove from list? */
-    if (isset($_POST['del']) && isset($_POST['recipient'])){
-      foreach ($_POST['recipient'] as $key){
+    if (isset($_POST['del']) && isset($_POST['recipient'])) {
+      foreach ($_POST['recipient'] as $key) {
           unset($this->recipients[$key]);
       }
     }
 
     /* Create templating instance */
-    $smarty= get_smarty();
-    $smarty->assign("acl_readable",$this->acl_is_readable(""));
-    if(!$this->acl_is_readable("")){
-      return ($smarty->fetch (get_template_path('acl.tpl')));
+    $smarty = get_smarty();
+    $smarty->assign("acl_readable", $this->acl_is_readable(""));
+    if (!$this->acl_is_readable("")) {
+      return $smarty->fetch (get_template_path('acl.tpl'));
     }
 
     if ($this->dialogState == 'head') {
       /* Draw list */
-      $aclList= new divSelectBox("aclList");
+      $aclList = new divSelectBox("aclList");
       $aclList->SetHeight(450);
 
       /* Fill in entries */
       foreach ($this->gosaAclEntry as $key => $entry) {
-        if(!$this->acl_is_readable("")) continue;
+        if (!$this->acl_is_readable("")) {
+          continue;
+        }
 
-        $action ="";
+        $action = "";
 
         if ($this->acl_is_readable("")) {
           $link = "<a href=?plug=".$_GET['plug']."&amp;id=".$key."&amp;act=edit>".$this->assembleAclSummary($entry)."</a>";
@@ -462,26 +468,26 @@ class acl extends plugin
           $link = $this->assembleAclSummary($entry);
         }
 
-        $field1= array("html" => $this->aclTypes[$entry['type']], "attach" => "style='width:150px'");
-        $field2= array("html" => $link);
+        $field1 = array("html" => $this->aclTypes[$entry['type']], "attach" => "style='width:150px'");
+        $field2 = array("html" => $link);
 
-        if($this->acl_is_writeable("")){
-          $action.= "<input type='image' name='sortup_$key' alt='up'
+        if ($this->acl_is_writeable("")) {
+          $action .= "<input type='image' name='sortup_$key' alt='up'
             title='"._("Up")."' src='images/lists/sort-up.png'/>";
-          $action.= "<input type='image' name='sortdown_$key' alt='down'
+          $action .= "<input type='image' name='sortdown_$key' alt='down'
             title='"._("Down")."' src='images/lists/sort-down.png'/>";
         }
 
-        if($this->acl_is_readable("")){
-          $action.= "<input class='center' type='image' src='images/lists/edit.png'
+        if ($this->acl_is_readable("")) {
+          $action .= "<input class='center' type='image' src='images/lists/edit.png'
             alt='"._("Edit")."' name='acl_edit_$key' title='".msgPool::editButton(_("ACL"))."'>";
         }
-        if($this->acl_is_removeable("")){
-          $action.= "<input class='center' type='image' src='images/lists/trash.png'
+        if ($this->acl_is_removeable("")) {
+          $action .= "<input class='center' type='image' src='images/lists/trash.png'
             alt='"._("Delete")."' name='acl_del_$key' title='".msgPool::delButton(_("ACL"))."'>";
         }
 
-        $field3= array("html" => $action, "attach" => "style='border-right:0px;width:50px;text-align:right;'");
+        $field3 = array("html" => $action, "attach" => "style='border-right:0px;width:50px;text-align:right;'");
         $aclList->AddEntry(array($field1, $field2, $field3));
       }
 
@@ -490,7 +496,7 @@ class acl extends plugin
 
     if ($this->dialogState == 'create') {
       /* Draw list */
-      $aclList= new divSelectBox("aclList");
+      $aclList = new divSelectBox("aclList");
       $aclList->SetHeight(150);
 
       /* Add settings for all categories to the (permanent) list */
@@ -513,24 +519,24 @@ class acl extends plugin
 
         /* Set summary... */
         if ($summary == "") {
-          $summary= '<i>'._("No ACL settings for this category!").'</i>';
+          $summary = '<i>'._("No ACL settings for this category!").'</i>';
         } else {
-          $summary= sprintf(_("Contains ACLs for these objects: %s"), preg_replace('/, $/', '', $summary));
+          $summary = sprintf(_("Contains ACLs for these objects: %s"), preg_replace('/, $/', '', $summary));
         }
 
-        $actions ="";
+        $actions = "";
         if ($this->acl_is_readable("")) {
-          $actions= "<input class='center' type='image' src='images/lists/edit.png'
+          $actions = "<input class='center' type='image' src='images/lists/edit.png'
             alt='"._("Edit")."' name='cat_edit_$section' title='".msgPool::editButton(_("category ACL"))."'>";
         }
         if ($this->acl_is_removeable()) {
-          $actions.= "<input class='center' type='image' src='images/lists/trash.png'
+          $actions .= "<input class='center' type='image' src='images/lists/trash.png'
             alt='"._("Delete")."' name='cat_del_$section' title='".msgPool::delButton(_("category ACL"))."'>";
         }
 
-        $field1= array("html" => $infos['description'], "attach" => "style='width:100px'");
-        $field2= array("html" => $summary);
-        $field3= array("html" => $actions, "attach" => "style='border-right:0px;width:50px'");
+        $field1 = array("html" => $infos['description'], "attach" => "style='width:100px'");
+        $field2 = array("html" => $summary);
+        $field3 = array("html" => $actions, "attach" => "style='border-right:0px;width:50px'");
         $aclList->AddEntry(array($field1, $field2, $field3));
       }
 
@@ -543,21 +549,21 @@ class acl extends plugin
 
       /* Assign possible target types */
       $smarty->assign("targets", $this->targets);
-      foreach ($this->attributes as $attr){
+      foreach ($this->attributes as $attr) {
         $smarty->assign($attr, $this->$attr);
       }
 
 
       /* Generate list */
-      $tmp= array();
+      $tmp = array();
       if ($this->target == "group" && !isset($this->recipients["G:*"])) {
-        $tmp["G:*"]= _("All users");
+        $tmp["G:*"] = _("All users");
       }
       foreach (array("user" => "users", "group" => "groups") as $field => $arr) {
-        if ($this->target == $field){
-          foreach ($this->$arr as $key => $value){
-            if (!isset($this->recipients[$key])){
-              $tmp[$key]= $value;
+        if ($this->target == $field) {
+          foreach ($this->$arr as $key => $value) {
+            if (!isset($this->recipients[$key])) {
+              $tmp[$key] = $value;
             }
           }
         }
@@ -617,16 +623,16 @@ class acl extends plugin
    */
   function sort_by_priority($list)
   {
-    $tmp= session::global_get('plist');
-    $plist= $tmp->info;
+    $tmp    = session::global_get('plist');
+    $plist  = $tmp->info;
     asort($plist);
     $newSort = array();
 
-    foreach($list as $name => $translation){
-      $na  =  preg_replace("/^.*\//","",$name);
+    foreach ($list as $name => $translation) {
+      $na   = preg_replace("/^.*\//", "", $name);
       $prio = 0;
-      if(isset($plist[$na]['plPriority'])){
-        $prio=  $plist[$na]['plPriority'] ;
+      if (isset($plist[$na]['plPriority'])) {
+        $prio = $plist[$na]['plPriority'];
       }
 
       $newSort[$name] = $prio;
@@ -635,10 +641,10 @@ class acl extends plugin
     asort($newSort);
 
     $ret = array();
-    foreach($newSort as $name => $prio){
+    foreach ($newSort as $name => $prio) {
       $ret[$name] = $list[$name];
     }
-    return($ret);
+    return $ret;
   }
 
   /*!
@@ -648,29 +654,29 @@ class acl extends plugin
    */
   function buildRoleSelector($list)
   {
-    $D_List =new divSelectBox("Acl_Roles");
+    $D_List = new divSelectBox("Acl_Roles");
 
     $selected = $this->aclContents;
-    if(!is_string($this->aclContents) || !isset($list[$this->aclContents])){
+    if (!is_string($this->aclContents) || !isset($list[$this->aclContents])) {
       $selected = key($list);
     }
 
-    $str ="";
-    foreach($list as $dn => $values){
+    $str = "";
+    foreach ($list as $dn => $values) {
 
-      if($dn == $selected){
+      if ($dn == $selected) {
         $option = "<input type='radio' name='selected_role' value='".base64_encode($dn)."' checked>";
-      }else{
+      } else {
         $option = "<input type='radio' name='selected_role' value='".base64_encode($dn)."'>";
       }
 
-      $field1 = array("html" => $option) ;
-      $field2 = array("html" => $values['cn'], "attach" => "style='width:200px;'") ;
-      $field3 = array("html" => $values['description'],"attach" => "style='border-right:0px;'") ;
+      $field1 = array("html" => $option);
+      $field2 = array("html" => $values['cn'], "attach" => "style='width:200px;'");
+      $field3 = array("html" => $values['description'],"attach" => "style='border-right:0px;'");
 
       $D_List->AddEntry(array($field1,$field2,$field3));
     }
-    return($D_List->DrawList());
+    return $D_List->DrawList();
   }
 
   /*!
@@ -682,16 +688,16 @@ class acl extends plugin
    */
   function buildAclSelector($list)
   {
-    $display= "<input type='hidden' name='acl_dummy_0_0_0' value='1'>";
-    $cols= 3;
-    $tmp= session::global_get('plist');
-    $plist= $tmp->info;
+    $display  = "<input type='hidden' name='acl_dummy_0_0_0' value='1'>";
+    $cols     = 3;
+    $tmp      = session::global_get('plist');
+    $plist    = $tmp->info;
     asort($plist);
 
     /* Add select all/none buttons */
     $style = "style='width:100px;'";
 
-    if($this->acl_is_writeable("")){
+    if ($this->acl_is_writeable("")) {
       $display .= "<input ".$style." type='button' name='toggle_all_create' onClick=\"acl_toggle_all('_0_c$');\" value='Toggle C'>";
       $display .= "<input ".$style." type='button' name='toggle_all_move'   onClick=\"acl_toggle_all('_0_m$');\" value='Toggle M'>";
       $display .= "<input ".$style." type='button' name='toggle_all_remove' onClick=\"acl_toggle_all('_0_d$');\" value='Toggle D'> - ";
@@ -703,17 +709,17 @@ class acl extends plugin
 
       $display .= "<br>";
 
-      $style = "style='width:50px;'";
-      $display .= "<input ".$style." type='button' name='set_true_all_create' onClick=\"acl_set_all('_0_c$',true);\" value='C+'>";
-      $display .= "<input ".$style." type='button' name='set_false_all_create' onClick=\"acl_set_all('_0_c$',false);\" value='C-'>";
-      $display .= "<input ".$style." type='button' name='set_true_all_move' onClick=\"acl_set_all('_0_m$',true);\" value='M+'>";
-      $display .= "<input ".$style." type='button' name='set_false_all_move' onClick=\"acl_set_all('_0_m$',false);\" value='M-'>";
-      $display .= "<input ".$style." type='button' name='set_true_all_remove' onClick=\"acl_set_all('_0_d$',true);\" value='D+'>";
-      $display .= "<input ".$style." type='button' name='set_false_all_remove' onClick=\"acl_set_all('_0_d$',false);\" value='D-'> - ";
-      $display .= "<input ".$style." type='button' name='set_true_all_read' onClick=\"acl_set_all('_0_r$',true);\" value='R+'>";
-      $display .= "<input ".$style." type='button' name='set_false_all_read' onClick=\"acl_set_all('_0_r$',false);\" value='R-'>";
-      $display .= "<input ".$style." type='button' name='set_true_all_write' onClick=\"acl_set_all('_0_w$',true);\" value='W+'>";
-      $display .= "<input ".$style." type='button' name='set_false_all_write' onClick=\"acl_set_all('_0_w$',false);\" value='W-'> - ";
+      $style    = "style='width:50px;'";
+      $display  .= "<input ".$style." type='button' name='set_true_all_create' onClick=\"acl_set_all('_0_c$',true);\" value='C+'>";
+      $display  .= "<input ".$style." type='button' name='set_false_all_create' onClick=\"acl_set_all('_0_c$',false);\" value='C-'>";
+      $display  .= "<input ".$style." type='button' name='set_true_all_move' onClick=\"acl_set_all('_0_m$',true);\" value='M+'>";
+      $display  .= "<input ".$style." type='button' name='set_false_all_move' onClick=\"acl_set_all('_0_m$',false);\" value='M-'>";
+      $display  .= "<input ".$style." type='button' name='set_true_all_remove' onClick=\"acl_set_all('_0_d$',true);\" value='D+'>";
+      $display  .= "<input ".$style." type='button' name='set_false_all_remove' onClick=\"acl_set_all('_0_d$',false);\" value='D-'> - ";
+      $display  .= "<input ".$style." type='button' name='set_true_all_read' onClick=\"acl_set_all('_0_r$',true);\" value='R+'>";
+      $display  .= "<input ".$style." type='button' name='set_false_all_read' onClick=\"acl_set_all('_0_r$',false);\" value='R-'>";
+      $display  .= "<input ".$style." type='button' name='set_true_all_write' onClick=\"acl_set_all('_0_w$',true);\" value='W+'>";
+      $display  .= "<input ".$style." type='button' name='set_false_all_write' onClick=\"acl_set_all('_0_w$',false);\" value='W-'> - ";
 
       $display .= "<input ".$style." type='button' name='set_true_all_read' onClick=\"acl_set_all('[^0]_r$',true);\" value='R+'>";
       $display .= "<input ".$style." type='button' name='set_false_all_read' onClick=\"acl_set_all('[^0]_r$',false);\" value='R-'>";
@@ -722,23 +728,23 @@ class acl extends plugin
     }
 
     /* Build general objects */
-    $list =$this->sort_by_priority($list);
-    foreach ($list as $key => $name){
+    $list = $this->sort_by_priority($list);
+    foreach ($list as $key => $name) {
 
       /* Create sub acl if it does not exist */
-      if (!isset($this->aclContents[$key])){
-        $this->aclContents[$key]= array();
+      if (!isset($this->aclContents[$key])) {
+        $this->aclContents[$key] = array();
       }
-      if(!isset($this->aclContents[$key][0])){
-        $this->aclContents[$key][0]= '';
+      if (!isset($this->aclContents[$key][0])) {
+        $this->aclContents[$key][0] = '';
       }
 
-      $currentAcl= $this->aclContents[$key];
+      $currentAcl = $this->aclContents[$key];
 
       /* Get the overall plugin acls
        */
-      $overall_acl ="";
-      if(isset($currentAcl[0])){
+      $overall_acl = "";
+      if (isset($currentAcl[0])) {
         $overall_acl = $currentAcl[0];
       }
 
@@ -746,135 +752,135 @@ class acl extends plugin
       $expand = count($currentAcl) > 1 || $currentAcl[0] != "";
 
       /* Object header */
-      $tname= preg_replace("/[^a-z0-9]/i","_",$name);
+      $tname = preg_replace("/[^a-z0-9]/i", "_", $name);
 
-      if($expand){
+      if ($expand) {
         $back_color = "#C8C8FF";
-      }else{
+      } else {
         $back_color = "#C8C8C8";
       }
 
-      if(session::global_get('js')) {
-        if(isset($_SERVER['HTTP_USER_AGENT']) &&
-             (preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) ||
-             (preg_match("/presto/i",$_SERVER['HTTP_USER_AGENT']))) {
-          $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
-                     "\n  <tr>".
-                     "\n    <td style='background-color:{$back_color};height:1.8em;' colspan=".($cols-1)."><b>"._("Object").": $name</b></td>".
-                     "\n    <td align='right' style='background-color:{$back_color};height:1.8em;'>".
-                     "\n    <input type='button' onclick=\"$('{$tname}').toggle();\" value='"._("Show/hide advanced settings")."' /></td>".
-                     "\n  </tr>";
-        } else if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT'])) {
-          $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
-                     "\n  <tr>".
-                     "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=".($cols-1)."><b>"._("Object").": $name</b></td>".
-                     "\n    <td align='right' style='background-color:#C8C8C8;height:1.8em;'>".
-                     "\n    <input type='button' onclick=\"$('{$tname}').toggle();\" value='"._("Show/hide advanced settings")."' /></td>".
-                     "\n  </tr>";
+      if (session::global_get('js')) {
+        if (isset($_SERVER['HTTP_USER_AGENT']) &&
+             (preg_match("/gecko/i", $_SERVER['HTTP_USER_AGENT'])) ||
+             (preg_match("/presto/i", $_SERVER['HTTP_USER_AGENT']))) {
+          $display .= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
+                      "\n  <tr>".
+                      "\n    <td style='background-color:{$back_color};height:1.8em;' colspan=".($cols - 1)."><b>"._("Object").": $name</b></td>".
+                      "\n    <td align='right' style='background-color:{$back_color};height:1.8em;'>".
+                      "\n    <input type='button' onclick=\"$('{$tname}').toggle();\" value='"._("Show/hide advanced settings")."' /></td>".
+                      "\n  </tr>";
+        } elseif (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i", $_SERVER['HTTP_USER_AGENT'])) {
+          $display .= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
+                      "\n  <tr>".
+                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=".($cols - 1)."><b>"._("Object").": $name</b></td>".
+                      "\n    <td align='right' style='background-color:#C8C8C8;height:1.8em;'>".
+                      "\n    <input type='button' onclick=\"$('{$tname}').toggle();\" value='"._("Show/hide advanced settings")."' /></td>".
+                      "\n  </tr>";
         } else {
-          $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
-                     "\n  <tr>".
-                     "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=$cols><b>"._("Object").": $name</b></td>".
-                     "\n  </tr>";
+          $display .= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
+                      "\n  <tr>".
+                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=$cols><b>"._("Object").": $name</b></td>".
+                      "\n  </tr>";
         }
       } else {
-          $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
-                     "\n  <tr>".
-                     "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=$cols><b>"._("Object").": $name</b></td>".
-                     "\n  </tr>";
+          $display .= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
+                      "\n  <tr>".
+                      "\n    <td style='background-color:#C8C8C8;height:1.8em;' colspan=$cols><b>"._("Object").": $name</b></td>".
+                      "\n  </tr>";
       }
 
       /* Generate options */
-      $spc= "&nbsp;&nbsp;";
-      $options= $this->mkchkbx($key."_0_c",  _("Create objects"), preg_match('/c/', $overall_acl)).$spc;
-      $options.= $this->mkchkbx($key."_0_m", _("Move objects"), preg_match('/m/', $overall_acl)).$spc;
-      $options.= $this->mkchkbx($key."_0_d", _("Remove objects"), preg_match('/d/', $overall_acl)).$spc;
-      if ($plist[preg_replace('%^.*/%', '', $key)]['plSelfModify']){
-        $options.= $this->mkchkbx($key."_0_s", _("Grant permission to owner"), preg_match('/s/', $overall_acl)).$spc;
+      $spc      = "&nbsp;&nbsp;";
+      $options  = $this->mkchkbx($key."_0_c",  _("Create objects"), preg_match('/c/', $overall_acl)).$spc;
+      $options  .= $this->mkchkbx($key."_0_m", _("Move objects"), preg_match('/m/', $overall_acl)).$spc;
+      $options  .= $this->mkchkbx($key."_0_d", _("Remove objects"), preg_match('/d/', $overall_acl)).$spc;
+      if ($plist[preg_replace('%^.*/%', '', $key)]['plSelfModify']) {
+        $options .= $this->mkchkbx($key."_0_s", _("Grant permission to owner"), preg_match('/s/', $overall_acl)).$spc;
       }
 
       /* Global options */
-      $more_options= $this->mkchkbx($key."_0_r",  _("read"), preg_match('/r/', $overall_acl)).$spc;
-      $more_options.= $this->mkchkbx($key."_0_w", _("write"), preg_match('/w/', $overall_acl));
+      $more_options = $this->mkchkbx($key."_0_r",  _("read"), preg_match('/r/', $overall_acl)).$spc;
+      $more_options .= $this->mkchkbx($key."_0_w", _("write"), preg_match('/w/', $overall_acl));
 
-      $display.= "\n  <tr>".
-                 "\n    <td style='background-color:#E0E0E0' colspan=".($cols-1).">$options</td>".
-                 "\n    <td style='background-color:#D4D4D4'>&nbsp;"._("Complete object").": $more_options</td>".
-                 "\n  </tr>";
+      $display .= "\n  <tr>".
+                  "\n    <td style='background-color:#E0E0E0' colspan=".($cols - 1).">$options</td>".
+                  "\n    <td style='background-color:#D4D4D4'>&nbsp;"._("Complete object").": $more_options</td>".
+                  "\n  </tr>";
 
       /* Walk through the list of attributes */
-      $cnt= 1;
-      $splist= $plist[preg_replace('%^.*/%', '', $key)]['plProvidedAcls'];
-      if(session::global_get('js')) {
-        if(isset($_SERVER['HTTP_USER_AGENT']) &&
-            (preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) || (preg_match("/presto/i",$_SERVER['HTTP_USER_AGENT']))) {
-          $display.= "\n  <tr id='tr_$tname' style='vertical-align:top;height:0px;'>".
-                     "\n    <td colspan=".$cols.">".
-                     "\n      <div id='$tname' style='overflow:hidden; display:none;vertical-align:top;width:100%;'>".
-                     "\n        <table style='width:100%;'>";
-        } else if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT'])) {
-          $display.= "\n  <tr id='tr_$tname' style='vertical-align:top;height:0px;'>".
-                     "\n    <td colspan=".$cols.">".
-                     "\n      <div id='$tname' style='position:absolute;overflow:hidden;display:none;;vertical-align:top;width:100%;'>".
-                     "\n        <table style='width:100%;'>";
-        }else{
+      $cnt    = 1;
+      $splist = $plist[preg_replace('%^.*/%', '', $key)]['plProvidedAcls'];
+      if (session::global_get('js')) {
+        if (isset($_SERVER['HTTP_USER_AGENT']) &&
+            (preg_match("/gecko/i", $_SERVER['HTTP_USER_AGENT'])) || (preg_match("/presto/i", $_SERVER['HTTP_USER_AGENT']))) {
+          $display .= "\n  <tr id='tr_$tname' style='vertical-align:top;height:0px;'>".
+                      "\n    <td colspan=".$cols.">".
+                      "\n      <div id='$tname' style='overflow:hidden; display:none;vertical-align:top;width:100%;'>".
+                      "\n        <table style='width:100%;'>";
+        } else if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i", $_SERVER['HTTP_USER_AGENT'])) {
+          $display .= "\n  <tr id='tr_$tname' style='vertical-align:top;height:0px;'>".
+                      "\n    <td colspan=".$cols.">".
+                      "\n      <div id='$tname' style='position:absolute;overflow:hidden;display:none;;vertical-align:top;width:100%;'>".
+                      "\n        <table style='width:100%;'>";
+        } else {
         }
       }
 
 
-      foreach($splist as $attr => $dsc){
+      foreach ($splist as $attr => $dsc) {
 
         /* Skip pl* attributes, they are internal... */
-        if (preg_match('/^pl[A-Z]+.*$/', $attr)){
+        if (preg_match('/^pl[A-Z]+.*$/', $attr)) {
           continue;
         }
 
         /* Open table row */
-        if ($cnt == 1){
-          $display.= "\n  <tr>";
+        if ($cnt == 1) {
+          $display .= "\n  <tr>";
         }
 
         /* Close table row */
-        if ($cnt == $cols){
-          $cnt= 1;
-          $rb= "";
-          $end= "\n  </tr>";
+        if ($cnt == $cols) {
+          $cnt  = 1;
+          $rb   = "";
+          $end  = "\n  </tr>";
         } else {
           $cnt++;
-          $rb= "border-right:1px solid #A0A0A0;";
-          $end= "";
+          $rb   = "border-right:1px solid #A0A0A0;";
+          $end  = "";
         }
 
         /* Collect list of attributes */
-        $state= "";
-        if (isset($currentAcl[$attr])){
-          $state= $currentAcl[$attr];
+        $state = "";
+        if (isset($currentAcl[$attr])) {
+          $state = $currentAcl[$attr];
         }
-        $display.= "\n    <td style='border-top:1px solid #A0A0A0;${rb}width:".(int)(100/$cols)."%'>".
-                   "\n      <b>$dsc</b> ($attr)<br>".$this->mkrwbx($key."_".$attr, $state)."</td>$end";
+        $display .= "\n    <td style='border-top:1px solid #A0A0A0;${rb}width:".(int)(100 / $cols)."%'>".
+                    "\n      <b>$dsc</b> ($attr)<br>".$this->mkrwbx($key."_".$attr, $state)."</td>$end";
       }
 
       /* Fill missing td's if needed */
-      if (--$cnt != $cols && $cnt != 0){
-       $display.= str_repeat("\n    <td style='border-top:1px solid #A0A0A0; width:".(int)(100/$cols)."%'>&nbsp;</td>", $cols-$cnt);
+      if (--$cnt != $cols && $cnt != 0) {
+        $display .= str_repeat("\n    <td style='border-top:1px solid #A0A0A0; width:".(int)(100 / $cols)."%'>&nbsp;</td>", $cols - $cnt);
       }
 
-      if(session::global_get('js')) {
-        if(isset($_SERVER['HTTP_USER_AGENT']) &&
-            (preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) ||
-            (preg_match("/presto/i",$_SERVER['HTTP_USER_AGENT'])) ||
-            (preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT']))) {
-          $display.= "\n        </table>".
-                     "\n      </div>".
-                     "\n    </td>".
-                     "\n  </tr>";
+      if (session::global_get('js')) {
+        if (isset($_SERVER['HTTP_USER_AGENT']) &&
+            (preg_match("/gecko/i", $_SERVER['HTTP_USER_AGENT'])) ||
+            (preg_match("/presto/i", $_SERVER['HTTP_USER_AGENT'])) ||
+            (preg_match("/ie/i", $_SERVER['HTTP_USER_AGENT']))) {
+          $display .= "\n        </table>".
+                      "\n      </div>".
+                      "\n    </td>".
+                      "\n  </tr>";
         }
       }
 
-      $display.= "\n</table><br />\n";
+      $display .= "\n</table><br />\n";
     }
 
-    return ($display);
+    return $display;
   }
 
   /*!
@@ -888,14 +894,14 @@ class acl extends plugin
    *
    * \return String containing checkbox
    */
-  function mkchkbx($name, $text, $state= FALSE)
+  function mkchkbx($name, $text, $state = FALSE)
   {
-    $state= $state?"checked":"";
-    if($this->acl_is_writeable("")){
-      $tname= preg_replace("/[^a-z0-9]/i","_",$name);
-      return "\n      <input id='acl_$tname' type=checkbox name='acl_$name' $state>".
-        "\n      <label for='acl_$tname'>$text</label>";
-    }else{
+    $state = ($state?"checked":"");
+    if ($this->acl_is_writeable("")) {
+      $tname = preg_replace("/[^a-z0-9]/i", "_", $name);
+      return  "\n      <input id='acl_$tname' type=checkbox name='acl_$name' $state>".
+              "\n      <label for='acl_$tname'>$text</label>";
+    } else {
       return "\n <input type='checkbox' disabled name='dummy_".microtime(1)."' $state>$text";
     }
   }
@@ -909,20 +915,20 @@ class acl extends plugin
    *
    * \return String containing checkbox
    */
-  function mkrwbx($name, $state= "")
+  function mkrwbx($name, $state = "")
   {
-    $rstate= preg_match('/r/', $state)?'checked':'';
-    $wstate= preg_match('/w/', $state)?'checked':'';
-    $tname= preg_replace("/[^a-z0-9]/i","_",$name);
-
-    if($this->acl_is_writeable("")){
-      return ("\n      <input id='acl_".$tname."_r' type=checkbox name='acl_${name}_r' $rstate>".
-          "\n      <label for='acl_".$tname."_r'>"._("read")."</label>".
-          "\n      <input id='acl_".$tname."_w' type=checkbox name='acl_${name}_w' $wstate>".
-          "\n      <label for='acl_".$tname."_w'>"._("write")."</label>");
-    }else{
-      return ("\n      <input disabled type=checkbox name='dummy_".microtime(1)."' $rstate>"._("read").
-          "\n      <input disabled type=checkbox name='dummy_".microtime(1)."' $wstate>"._("write"));
+    $rstate = (preg_match('/r/', $state)?'checked':'');
+    $wstate = (preg_match('/w/', $state)?'checked':'');
+    $tname  = preg_replace("/[^a-z0-9]/i", "_", $name);
+
+    if ($this->acl_is_writeable("")) {
+      return  "\n      <input id='acl_".$tname."_r' type=checkbox name='acl_${name}_r' $rstate>".
+              "\n      <label for='acl_".$tname."_r'>"._("read")."</label>".
+              "\n      <input id='acl_".$tname."_w' type=checkbox name='acl_${name}_w' $wstate>".
+              "\n      <label for='acl_".$tname."_w'>"._("write")."</label>";
+    } else {
+      return  "\n      <input disabled type=checkbox name='dummy_".microtime(1)."' $rstate>"._("read").
+              "\n      <input disabled type=checkbox name='dummy_".microtime(1)."' $wstate>"._("write");
     }
   }
 
@@ -933,32 +939,31 @@ class acl extends plugin
    */
   static function explodeACL($acl)
   {
-
-    $list= explode(':', $acl);
-    if(count($list) == 5){
-      list($index, $type,$member,$permission,$filter)= $list;
+    $list = explode(':', $acl);
+    if (count($list) == 5) {
+      list($index, $type,$member,$permission,$filter) = $list;
       $filter = base64_decode($filter);
-    }else{
+    } else {
       $filter = "";
-      list($index, $type,$member,$permission)= $list;
+      list($index, $type,$member,$permission) = $list;
     }
 
-    $a= array( $index => array("type" => $type,
-                               "filter"=> $filter,
-                               "members" => acl::extractMembers($acl,$type == "role")));
+    $a = array( $index => array("type"     => $type,
+                               "filter"   => $filter,
+                               "members"  => acl::extractMembers($acl, $type == "role")));
 
     /* Handle different types */
-    switch ($type){
+    switch ($type) {
 
       case 'psub':
       case 'sub':
       case 'one':
       case 'base':
-        $a[$index]['acl']= acl::extractACL($acl);
+        $a[$index]['acl'] = acl::extractACL($acl);
         break;
 
       case 'role':
-        $a[$index]['acl']= base64_decode(preg_replace('/^[^:]+:[^:]+:([^:]+).*$/', '\1', $acl));
+        $a[$index]['acl'] = base64_decode(preg_replace('/^[^:]+:[^:]+:([^:]+).*$/', '\1', $acl));
         break;
 
       case 'reset':
@@ -966,9 +971,9 @@ class acl extends plugin
 
       default:
         msg_dialog::display(_("Internal error"), sprintf(_("Unkown ACL type '%s'!"), $type), ERROR_DIALOG);
-        $a= array();
+        $a = array();
     }
-    return ($a);
+    return $a;
   }
 
   /*!
@@ -980,53 +985,51 @@ class acl extends plugin
    *
    * \return an array with members
    */
-  static function extractMembers($acl,$role = FALSE)
+  static function extractMembers($acl, $role = FALSE)
   {
     global $config;
-    $a= array();
+    $a = array();
 
     /* Rip acl off the string, seperate by ',' and place it in an array */
-    if($role){
-      $ms= preg_replace('/^[^:]+:[^:]+:[^:]+:([^:]+).*$/', '\1', $acl);
-    }else{
-      $ms= preg_replace('/^[^:]+:[^:]+:([^:]+).*$/', '\1', $acl);
+    if ($role) {
+      $ms = preg_replace('/^[^:]+:[^:]+:[^:]+:([^:]+).*$/', '\1', $acl);
+    } else {
+      $ms = preg_replace('/^[^:]+:[^:]+:([^:]+).*$/', '\1', $acl);
     }
-    if ($ms == $acl){
+    if ($ms == $acl) {
       return $a;
     }
-    $ma= explode(',', $ms);
+    $ma = explode(',', $ms);
 
     /* Decode dn's, fill with informations from LDAP */
-    $ldap= $config->get_ldap_link();
-    foreach ($ma as $memberdn){
+    $ldap = $config->get_ldap_link();
+    foreach ($ma as $memberdn) {
       // Check for wildcard here
-      $dn= base64_decode($memberdn);
+      $dn = base64_decode($memberdn);
       if ($dn != "*") {
         $ldap->cat($dn, array('cn', 'objectClass', 'description', 'uid'));
 
         /* Found entry... */
-        if ($ldap->count()){
-          $attrs= $ldap->fetch();
-          if (in_array_ics('gosaAccount', $attrs['objectClass'])){
-            $a['U:'.$dn]= $attrs['cn'][0]." [".$attrs['uid'][0]."]";
+        if ($ldap->count()) {
+          $attrs = $ldap->fetch();
+          if (in_array_ics('gosaAccount', $attrs['objectClass'])) {
+            $a['U:'.$dn] = $attrs['cn'][0]." [".$attrs['uid'][0]."]";
           } else {
-            $a['G:'.$dn]= $attrs['cn'][0];
-            if (isset($attrs['description'][0])){
-              $a['G:'.$dn].= " [".$attrs['description'][0]."]";
+            $a['G:'.$dn] = $attrs['cn'][0];
+            if (isset($attrs['description'][0])) {
+              $a['G:'.$dn] .= " [".$attrs['description'][0]."]";
             }
           }
-
-        /* ... or not */
+          /* ... or not */
         } else {
-          $a['U:'.$dn]= sprintf(_("Unknown entry '%s'!"), $dn);
+          $a['U:'.$dn] = sprintf(_("Unknown entry '%s'!"), $dn);
         }
-
       } else {
-        $a['G:*']= sprintf(_("All users"));
+        $a['G:*'] = sprintf(_("All users"));
       }
     }
 
-    return ($a);
+    return $a;
   }
 
   /*!
@@ -1037,41 +1040,40 @@ class acl extends plugin
   static function extractACL($acl)
   {
     /* Rip acl off the string, seperate by ',' and place it in an array */
-    $as= preg_replace('/^[^:]+:[^:]+:[^:]*:([^:]*).*$/', '\1', $acl);
-    $aa= explode(',', $as);
-    $a= array();
+    $as = preg_replace('/^[^:]+:[^:]+:[^:]*:([^:]*).*$/', '\1', $acl);
+    $aa = explode(',', $as);
+    $a  = array();
 
     /* Dis-assemble single ACLs */
-    foreach($aa as $sacl){
+    foreach ($aa as $sacl) {
 
       /* Dis-assemble field ACLs */
-      $ao= explode('#', $sacl);
-      $gobject= "";
-      foreach($ao as $idx => $ssacl){
+      $ao       = explode('#', $sacl);
+      $gobject  = "";
+      foreach ($ao as $idx => $ssacl) {
 
         /* First is department with global acl */
-        $object= preg_replace('/^([^;]+);.*$/', '\1', $ssacl);
-        $gacl=   preg_replace('/^[^;]+;(.*)$/', '\1', $ssacl);
-        if ($idx == 0){
+        $object = preg_replace('/^([^;]+);.*$/', '\1', $ssacl);
+        $gacl   = preg_replace('/^[^;]+;(.*)$/', '\1', $ssacl);
+        if ($idx == 0) {
           /* Create hash for this object */
-          $gobject= $object;
-          $a[$gobject]= array();
+          $gobject      = $object;
+          $a[$gobject]  = array();
 
           /* Append ACL if set */
-          if ($gacl != ""){
-            $a[$gobject]= array($gacl);
+          if ($gacl != "") {
+            $a[$gobject] = array($gacl);
           }
         } else {
-
           /* All other entries get appended... */
-          list($field, $facl)= explode(';', $ssacl);
-          $a[$gobject][$field]= $facl;
+          list($field, $facl)   = explode(';', $ssacl);
+          $a[$gobject][$field]  = $facl;
         }
 
       }
     }
 
-    return ($a);
+    return $a;
   }
 
   /*!
@@ -1081,46 +1083,45 @@ class acl extends plugin
    */
   function assembleAclSummary($entry)
   {
-    $summary= "";
+    $summary = "";
 
     /* Summarize ACL */
-    if (isset($entry['acl'])){
-      $acl= "";
-
-      if($entry['type'] == "role"){
+    if (isset($entry['acl'])) {
+      $acl = "";
 
-        if(isset($this->roles[$entry['acl']])){
-          $summary.= sprintf(_("Role: %s"), $this->roles[$entry['acl']]['cn']);
-        }else{
-          $summary.= sprintf(_("Role: %s"), "<i>"._("unknown role")."</i>");
+      if ($entry['type'] == "role") {
+        if (isset($this->roles[$entry['acl']])) {
+          $summary .= sprintf(_("Role: %s"), $this->roles[$entry['acl']]['cn']);
+        } else {
+          $summary .= sprintf(_("Role: %s"), "<i>"._("unknown role")."</i>");
         }
-      }else{
-        foreach ($entry['acl'] as $name => $object){
-          if (count($object)){
-            $acl.= "$name, ";
+      } else {
+        foreach ($entry['acl'] as $name => $object) {
+          if (count($object)) {
+            $acl .= "$name, ";
           }
         }
-        $summary.= sprintf(_("Contains settings for these objects: %s"), preg_replace('/, $/', '', $acl));
+        $summary .= sprintf(_("Contains settings for these objects: %s"), preg_replace('/, $/', '', $acl));
       }
     }
 
 
     /* Summarize members */
-    if(!($this instanceOf aclrole)){
-      if ($summary != ""){
-        $summary.= ", ";
+    if (!($this instanceOf aclrole)) {
+      if ($summary != "") {
+        $summary .= ", ";
       }
-      if (count($entry['members'])){
-        $summary.= _("Members").": ";
-        foreach ($entry['members'] as $cn){
-          $cn= preg_replace('/ \[.*$/', '', $cn);
-          $summary.= $cn.", ";
+      if (count($entry['members'])) {
+        $summary .= _("Members").": ";
+        foreach ($entry['members'] as $cn) {
+          $cn       = preg_replace('/ \[.*$/', '', $cn);
+          $summary  .= $cn.", ";
         }
       } else {
-        $summary.= "<div style='color:red;'><i>"._("inactive")."&nbsp;-&nbsp;"._("No members")."</i></div>";
+        $summary .= "<div style='color:red;'><i>"._("inactive")."&nbsp;-&nbsp;"._("No members")."</i></div>";
       }
     }
-    return (preg_replace('/, $/', '', $summary));
+    return preg_replace('/, $/', '', $summary);
   }
 
   /*!
@@ -1128,23 +1129,24 @@ class acl extends plugin
    *
    * \param boolean $new false
    */
-  function loadAclEntry($new= FALSE)
+  function loadAclEntry($new = FALSE)
   {
     /* New entry gets presets... */
-    if ($new){
-      $this->aclType= 'base';
-      $this->aclFilter= "";
-      $this->recipients= array();
-      $this->aclContents= array();
+    if ($new) {
+      $this->aclType      = 'base';
+      $this->aclFilter    = "";
+      $this->recipients   = array();
+      $this->aclContents  = array();
     } else {
-      $acl= $this->gosaAclEntry[$this->currentIndex];
-      $this->aclType= $acl['type'];
-      $this->recipients= $acl['members'];
-      $this->aclContents= $acl['acl'];
-      $this->aclFilter= $acl['filter'];
+      $acl = $this->gosaAclEntry[$this->currentIndex];
+
+      $this->aclType      = $acl['type'];
+      $this->recipients   = $acl['members'];
+      $this->aclContents  = $acl['acl'];
+      $this->aclFilter    = $acl['filter'];
     }
 
-    $this->wasNewEntry= $new;
+    $this->wasNewEntry = $new;
   }
 
   /*!
@@ -1154,7 +1156,7 @@ class acl extends plugin
    */
   function aclPostHandler()
   {
-    if (isset($_POST['save_acl'])){
+    if (isset($_POST['save_acl'])) {
       $this->save();
       return TRUE;
     }
@@ -1173,8 +1175,8 @@ class acl extends plugin
   {
     plugin::PrepareForCopyPaste($source);
 
-    $dn = $source['dn'];
-    $acl_c = new acl($this->config, $dn, $this->parent);
+    $dn                 = $source['dn'];
+    $acl_c              = new acl($this->config, $dn, $this->parent);
     $this->gosaAclEntry = $acl_c->gosaAclEntry;
   }
 
@@ -1184,73 +1186,68 @@ class acl extends plugin
   function save()
   {
     /* Assemble ACL's */
-    $tmp_acl= array();
-
-    foreach ($this->gosaAclEntry as $prio => $entry){
-      $final= "";
-      $members= "";
-      if (isset($entry['members'])){
-        foreach ($entry['members'] as $key => $dummy){
-          $members.= base64_encode(preg_replace('/^.:/', '', $key)).',';
+    $tmp_acl = array();
+
+    foreach ($this->gosaAclEntry as $prio => $entry) {
+      $final    = "";
+      $members  = "";
+      if (isset($entry['members'])) {
+        foreach ($entry['members'] as $key => $dummy) {
+          $members .= base64_encode(preg_replace('/^.:/', '', $key)).',';
         }
       }
 
-      if($entry['type'] != "role"){
-        $final= $prio.":".$entry['type'].":".preg_replace('/,$/', '', $members);
-      }else{
-        $final= $prio.":".$entry['type'].":".base64_encode($entry['acl']).":".preg_replace('/,$/', '', $members);
+      if ($entry['type'] != "role") {
+        $final = $prio.":".$entry['type'].":".preg_replace('/,$/', '', $members);
+      } else {
+        $final = $prio.":".$entry['type'].":".base64_encode($entry['acl']).":".preg_replace('/,$/', '', $members);
       }
 
       /* ACL's if needed */
-      if ($entry['type'] != "reset" && $entry['type'] != "role"){
-        $acl= ":";
-        if (isset($entry['acl'])){
-          foreach ($entry['acl'] as $object => $contents){
-
+      if ($entry['type'] != "reset" && $entry['type'] != "role") {
+        $acl = ":";
+        if (isset($entry['acl'])) {
+          foreach ($entry['acl'] as $object => $contents) {
             /* Only save, if we've some contents in there... */
-            if (count($contents)){
-              $acl.= $object.";";
-
-              foreach($contents as $attr => $permission){
-
+            if (count($contents)) {
+              $acl .= $object.";";
+              foreach ($contents as $attr => $permission) {
                 /* First entry? Its the one for global settings... */
-                if ($attr == '0'){
-                  $acl.= $permission;
+                if ($attr == '0') {
+                  $acl .= $permission;
                 } else {
-                  $acl.= '#'.$attr.';'.$permission;
+                  $acl .= '#'.$attr.';'.$permission;
                 }
-
               }
-              $acl.= ',';
+              $acl .= ',';
             }
-
           }
         }
-        $final.= preg_replace('/,$/', '', $acl);
+        $final .= preg_replace('/,$/', '', $acl);
       }
 
       /* Append additional filter options
        */
-      if(!empty($entry['filter'])){
+      if (!empty($entry['filter'])) {
         $final .= ":".base64_encode($entry['filter']);
       }
 
-      $tmp_acl[]= $final;
+      $tmp_acl[] = $final;
     }
 
     /* Call main method */
     plugin::save();
 
     /* Finally (re-)assign it... */
-    $this->attrs['gosaAclEntry']= $tmp_acl;
+    $this->attrs['gosaAclEntry'] = $tmp_acl;
 
     /* Remove acl from this entry if it is empty... */
-    if (!count($tmp_acl)){
+    if (!count($tmp_acl)) {
       /* Remove attribute */
-      if ($this->initially_was_account){
-        $this->attrs['gosaAclEntry']= array();
+      if ($this->initially_was_account) {
+        $this->attrs['gosaAclEntry'] = array();
       } else {
-        if (isset($this->attrs['gosaAclEntry'])){
+        if (isset($this->attrs['gosaAclEntry'])) {
           unset($this->attrs['gosaAclEntry']);
         }
       }
@@ -1314,10 +1311,7 @@ class acl extends plugin
       "plObjectType"  => array("acl" => array("name"  => _("ACL"),
                                               "filter"  => "objectClass=gosaAcl")),
 
-      "plProvidedAcls"=> array(
-//        "cn"          => _("Role name"),
-//        "description" => _("Role description")
-      )
+      "plProvidedAcls"  => array()
     );
   }
 
@@ -1342,39 +1336,39 @@ class acl extends plugin
 
     $ldap = $config->get_ldap_link();
     $ldap->cd($config->current['BASE']);
-    $ldap->search("(&(objectClass=gosaAcl)(gosaAclEntry=*".base64_encode($dn)."*))",array("gosaAclEntry","dn"));
-    $new_entries= array();
-    while($attrs = $ldap->fetch()){
+    $ldap->search("(&(objectClass=gosaAcl)(gosaAclEntry=*".base64_encode($dn)."*))", array("gosaAclEntry","dn"));
+    $new_entries = array();
+    while ($attrs = $ldap->fetch()) {
       if (!isset($attrs['gosaAclEntry'])) {
         continue;
       }
       unset($attrs['gosaAclEntry']['count']);
 
       // Remove entry directly
-      foreach($attrs['gosaAclEntry'] as $id => $entry){
-        $parts= explode(':',$entry);
-        $members= explode(',',$parts[2]);
-        $new_members= array();
-        foreach($members as $member) {
+      foreach ($attrs['gosaAclEntry'] as $id => $entry) {
+        $parts        = explode(':', $entry);
+        $members      = explode(',', $parts[2]);
+        $new_members  = array();
+        foreach ($members as $member) {
           if (base64_decode($member) != $dn) {
-            $new_members[]= $member;
+            $new_members[] = $member;
           } else {
-            fusiondirectory_log("modify","user/acl",$attrs['dn'],array(),sprintf("Removed acl for %s on object %s.",$dn,$attrs['dn']));
+            fusiondirectory_log("modify", "user/acl", $attrs['dn'], array(), sprintf("Removed acl for %s on object %s.", $dn, $attrs['dn']));
           }
         }
 
         /* We can completely remove the entry if there are no members anymore */
         if (count($new_members)) {
-          $parts[2]= implode(",", $new_members);
-          $new_entries[]= implode(":", $parts);
+          $parts[2]       = implode(",", $new_members);
+          $new_entries[]  = implode(":", $parts);
         }
       }
 
       // There should be a modification, so write it back
       $ldap->cd($attrs['dn']);
-      $new_attrs= array("gosaAclEntry" => $new_entries);
+      $new_attrs = array("gosaAclEntry" => $new_entries);
       $ldap->modify($new_attrs);
-      if (!$ldap->success()){
+      if (!$ldap->success()) {
         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()), ERROR_DIALOG);
       }
     }
@@ -1387,34 +1381,35 @@ class acl extends plugin
    *
    * \param String $dst The destination
    */
-  function update_acl_membership($src,$dst)
+  function update_acl_membership($src, $dst)
   {
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(&(objectClass=gosaAcl)(gosaAclEntry=*".base64_encode($src)."*))",array("gosaAclEntry","dn"));
-    while($attrs = $ldap->fetch()){
+    $ldap->search("(&(objectClass=gosaAcl)(gosaAclEntry=*".base64_encode($src)."*))", array("gosaAclEntry","dn"));
+    while ($attrs = $ldap->fetch()) {
       $acl = new acl($this->config, $attrs['dn'], $this->parent);
-      foreach($acl->gosaAclEntry as $id => $entry){
-        foreach($entry['members'] as $m_id => $member){
-          if($m_id == "U:".$src){
+      foreach ($acl->gosaAclEntry as $id => $entry) {
+        foreach ($entry['members'] as $m_id => $member) {
+          if ($m_id == "U:".$src) {
             unset($acl->gosaAclEntry[$id]['members'][$m_id]);
             $new = "U:".$dst;
+
             $acl->gosaAclEntry[$id]['members'][$new] = $new;
-            fusiondirectory_log("modify","user/acl",$attrs['dn'],array(),sprintf("Updated acl for user %s on object %s.",$src,$attrs['dn']));
+            fusiondirectory_log("modify", "user/acl", $attrs['dn'], array(), sprintf("Updated acl for user %s on object %s.", $src, $attrs['dn']));
           }
-          if($m_id == "G:".$src){
+          if ($m_id == "G:".$src) {
             unset($acl->gosaAclEntry[$id]['members'][$m_id]);
             $new = "G:".$dst;
+
             $acl->gosaAclEntry[$id]['members'][$new] = $new;
-            fusiondirectory_log("modify","group/acl",$attrs['dn'],array(),sprintf("Updated acl for group %s on object %s.",$src,$attrs['dn']));
+            fusiondirectory_log("modify", "group/acl", $attrs['dn'], array(), sprintf("Updated acl for group %s on object %s.", $src, $attrs['dn']));
           }
         }
       }
-      $acl -> save();
+      $acl->save();
     }
   }
 
 }
 
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
diff --git a/include/class_filterLDAP.inc b/include/class_filterLDAP.inc
index ed294472e94ff078b824f5a146f9ced4f3ff1976..9be8ff9c7f29775191e7b4a799846de84589c515 100644
--- a/include/class_filterLDAP.inc
+++ b/include/class_filterLDAP.inc
@@ -49,12 +49,12 @@ class filterLDAP {
    *
    * \param array $objectStorage
    */
-  static function query($parent,$base, $scope, $filter, $attributes, $category, $objectStorage= array(""))
+  static function query($parent, $base, $scope, $filter, $attributes, $category, $objectStorage = array(""))
   {
-    $config= session::global_get('config');
-    $ldap= $config->get_ldap_link(TRUE);
-    $flag= ($scope == "sub")?GL_SUBSEARCH:0;
-    $result= filterLDAP::get_list($parent,$base, $filter, $attributes, $category, $objectStorage, $flag | GL_SIZELIMIT);
+    $config = session::global_get('config');
+    $ldap   = $config->get_ldap_link(TRUE);
+    $flag   = ($scope == "sub"?GL_SUBSEARCH:0);
+    $result = filterLDAP::get_list($parent, $base, $filter, $attributes, $category, $objectStorage, $flag | GL_SIZELIMIT);
     return $result;
   }
 
@@ -86,7 +86,7 @@ class filterLDAP {
     }
 
     // Store in base - i.e. is a rdn value empty?
-    $storeOnBase = in_array("",$objectStorage);
+    $storeOnBase = in_array("", $objectStorage);
 
     $default_method = ($storeOnBase && !($flags & GL_SUBSEARCH))?"ls":"search";
 
@@ -99,7 +99,7 @@ class filterLDAP {
     } else {
       foreach ($objectStorage as $oc) {
         $oc = preg_replace('/,$/', '', $oc);
-        if (!strpos($oc,',')) {
+        if (!strpos($oc, ',')) {
           preg_match('/([^=]+)=(.*)$/', $oc, $m);
           if ($flags & GL_SUBSEARCH) {
             $bases[$base][] = $m[1].":dn:=".$m[2];
@@ -162,21 +162,21 @@ class filterLDAP {
       }
 
       // Check for size limit exceeded messages for GUI feedback
-      if (preg_match("/size limit/i", $ldap->get_error())){
+      if (preg_match("/size limit/i", $ldap->get_error())) {
         session::set('limit_exceeded', TRUE);
         $limit_exceeded = TRUE;
       }
 
       /* Crawl through result entries and perform the migration to the
          result array */
-      while($attrs = $ldap->fetch()) {
-        $dn= $ldap->getDN();
+      while ($attrs = $ldap->fetch()) {
+        $dn = $ldap->getDN();
 
         /* Convert dn into a printable format */
-        if ($flags & GL_CONVERT){
-          $attrs["dn"]= convert_department_dn($dn);
+        if ($flags & GL_CONVERT) {
+          $attrs["dn"] = convert_department_dn($dn);
         } else {
-          $attrs["dn"]= $dn;
+          $attrs["dn"] = $dn;
         }
 
         /* Skip ACL checks if we are forced to skip those checks */
diff --git a/include/class_ldapMultiplexer.inc b/include/class_ldapMultiplexer.inc
index 3884e73b908839f79a5bfa294aa28d21d05933fd..ff071ffbb704cd52efd8290010911e7947b76910 100644
--- a/include/class_ldapMultiplexer.inc
+++ b/include/class_ldapMultiplexer.inc
@@ -41,12 +41,13 @@ class ldapMultiplexer {
    *
    * \param $object Object LDAP
    */
-  public function __construct(&$object) {
+  public function __construct(&$object)
+  {
     /* Store object */
-    $this->object= $object;
+    $this->object = $object;
 
     /* Set result resource */
-    $this->sr= $this->object->getSearchResource();
+    $this->sr = $this->object->getSearchResource();
   }
 
   /*!
@@ -56,14 +57,15 @@ class ldapMultiplexer {
    *
    * \param $parameters Parameters for the method
    */
-  public function __call($methodName, $parameters) {
+  public function __call($methodName, $parameters)
+  {
     /* Add resource pointer if the mentioned methods are used */
-    if (preg_match('/^(search|ls|cat|fetch|clearResult|resetResult|count|getDN|recursive_remove|rmdir_recursive|create_missing_trees|import_single_entry|import_complete_ldif)$/', $methodName)){
+    if (preg_match('/^(search|ls|cat|fetch|clearResult|resetResult|count|getDN|recursive_remove|rmdir_recursive|create_missing_trees|import_single_entry|import_complete_ldif)$/', $methodName)) {
       array_unshift($parameters, $this->sr);
     }
 
-    $class= new ReflectionClass($this->object);
-    $method= $class->getMethod($methodName);
+    $class  = new ReflectionClass($this->object);
+    $method = $class->getMethod($methodName);
 
     return $method->invokeArgs($this->object, $parameters);
   }
@@ -73,7 +75,8 @@ class ldapMultiplexer {
    *
    * \param string $memberName
    */
-  public function __get($memberName) {
+  public function __get($memberName)
+  {
     return $this->object->$memberName;
   }
 
diff --git a/include/class_listing.inc b/include/class_listing.inc
index 4478010eb3f5ae89a0769df781f97e8d84d9f81c..049417d22a320ca3975863010e7341e0b1d4aa40 100644
--- a/include/class_listing.inc
+++ b/include/class_listing.inc
@@ -101,7 +101,7 @@ class listing {
     $this->registerElementFilter("actions", "listing::filterActions");
 
     // Load exporters
-    foreach ($class_mapping as $class => $dummy) {
+    foreach (array_keys($class_mapping) as $class) {
       if (preg_match('/Exporter$/', $class)) {
         $info = call_user_func(array($class, "getInfo"));
         if ($info != NULL) {
@@ -208,7 +208,7 @@ class listing {
 
     // Fill objectTypes from departments and xml definition
     $types = departmentManagement::get_support_departments();
-    foreach ($types as $class => $data) {
+    foreach ($types as $data) {
       $this->objectTypes[$data['OC']] = array("label" => $data['TITLE'],
                                   "objectClass" => $data['OC'],
                                   "image" => $data['IMG']);
@@ -509,7 +509,6 @@ class listing {
    */
   function update()
   {
-    global $config;
     $ui = get_userinfo();
 
     // Take care of base selector
@@ -529,7 +528,6 @@ class listing {
       $refresh = TRUE;
     }
 
-
     // Reset object counter / DN mapping
     $this->objectTypeCount = array();
     $this->objectDnMapping = array();
@@ -591,7 +589,7 @@ class listing {
 
       // Override base if we got signals from the navigation elements
       $action = "";
-      foreach ($_POST as $key => $value) {
+      foreach (array_keys($_POST) as $key) {
         if (preg_match('/^(ROOT|BACK|HOME)_x$/', $key, $match)) {
           $action = $match[1];
           break;
@@ -970,7 +968,6 @@ class listing {
         }
       }
 
-
       // If there's an objectclass definition and we don't have it
       // add an empty picture here.
       if (isset($action['objectclass'])) {
@@ -1093,8 +1090,6 @@ class listing {
       $enableRoot = FALSE;
     }
 
-    $listhead = "";
-
     /* Check if we are in users home  department */
     if (!count($deps) || $this->filter->base == get_base_from_people($ui->dn)) {
       $enableHome = FALSE;
@@ -1165,7 +1160,7 @@ class listing {
     }
 
     // Filter POST with "listing_" attributes
-    foreach ($_POST as $key => $prop) {
+    foreach (array_keys($_POST) as $key) {
 
       // Capture selections
       if (preg_match('/^listing_selected_[0-9]+$/', $key)) {
@@ -1418,7 +1413,6 @@ class listing {
     $ids    = $config->idepartments;
     $d      = $ui->get_module_departments($this->categories);
     $k_ids  = array_keys($ids);
-    $deps   = array_intersect($d, $k_ids);
 
     // Fill internal bases list
     $this->bases = array();
@@ -1451,7 +1445,7 @@ class listing {
     // of current base
     $filter = "(&(objectClass=gosaDepartment)(|";
     $attrs  = array("description", "objectClass");
-    foreach ($types as $name => $data) {
+    foreach ($types as $data) {
       $filter .= "(objectClass=".$data['OC'].")";
       $attrs[] = $data['ATTR'];
     }
@@ -1502,7 +1496,6 @@ class listing {
       $paste  = $paste || $ui->is_pasteable($this->base, $category) == 1;
     }
 
-
     // Draw entries that allow copy and cut
     if ($read) {
       // Copy entry
diff --git a/plugins/admin/acl/class_aclRole.inc b/plugins/admin/acl/class_aclRole.inc
index e535135b0b681e5bdc54693c427e1ef9a06a4ec1..f1753c467e7ee8313cea2ec8694c136b0eec662c 100644
--- a/plugins/admin/acl/class_aclRole.inc
+++ b/plugins/admin/acl/class_aclRole.inc
@@ -1,5 +1,4 @@
 <?php
-
 /*
   This code is part of FusionDirectory (http://www.fusiondirectory.org/)
   Copyright (C) 2003  Cajus Pollmeier
@@ -27,70 +26,71 @@ class aclrole extends acl
   var $objectclasses  = array('top','gosaRole');
 
   /* Helpers */
-  var $dialogState= "head";
-  var $aclType= "";
-  var $aclObject= "";
-  var $aclContents= array();
-  var $target= "group";
-  var $aclTypes= array();
-  var $recipients= array();
-  var $isContainer= TRUE;
-  var $currentIndex= 0;
-  var $wasNewEntry= FALSE;
-  var $savedAclContents= array();
+  var $dialogState      = "head";
+  var $aclType          = "";
+  var $aclObject        = "";
+  var $aclContents      = array();
+  var $target           = "group";
+  var $aclTypes         = array();
+  var $recipients       = array();
+  var $isContainer      = TRUE;
+  var $currentIndex     = 0;
+  var $wasNewEntry      = FALSE;
+  var $savedAclContents = array();
 
   /* Role attributes */
-  var $gosaAclTemplate= "";
-  var $cn = "";
-  var $orig_cn = "";
-  var $description = "";
+  var $gosaAclTemplate  = "";
+  var $cn               = "";
+  var $orig_cn          = "";
+  var $description      = "";
+  var $base             = "";
   var $orig_dn;
   var $orig_base;
-  var $base ="";
   var $baseSelector;
 
-  function aclrole (&$config,  $dn= NULL)
+  function aclrole (&$config, $dn = NULL)
   {
     /* Include config object */
     plugin::plugin($config, $dn);
 
-    if($this->dn == "new"){
+    if ($this->dn == "new") {
       $ui = get_userinfo();
-      $this->base= dn2base(session::global_is_set("CurrentMainBase")?"cn=test,".session::global_get("CurrentMainBase"):$ui->dn);
-    }else{
-      $this->base = preg_replace("/^[^,]+,[^,]+,/","",$this->dn);
-      new log("view","acl/".get_class($this),$this->dn);
+      $this->base = dn2base(session::global_is_set("CurrentMainBase")?"cn=test,".session::global_get("CurrentMainBase"):$ui->dn);
+    } else {
+      $this->base = preg_replace("/^[^,]+,[^,]+,/", "", $this->dn);
+      new log("view", "acl/".get_class($this), $this->dn);
     }
 
     /* Load ACL's */
-    $this->gosaAclTemplate= array();
-    if (isset($this->attrs["gosaAclTemplate"])){
-      for ($i= 0; $i<$this->attrs["gosaAclTemplate"]['count']; $i++){
-        $acl= $this->attrs["gosaAclTemplate"][$i];
-        $this->gosaAclTemplate= array_merge($this->gosaAclTemplate, $this->explodeACL($acl));
+    $this->gosaAclTemplate = array();
+    if (isset($this->attrs["gosaAclTemplate"])) {
+      for ($i = 0; $i < $this->attrs["gosaAclTemplate"]['count']; $i++) {
+        $acl = $this->attrs["gosaAclTemplate"][$i];
+
+        $this->gosaAclTemplate = array_merge($this->gosaAclTemplate, $this->explodeACL($acl));
       }
     }
     ksort($this->gosaAclTemplate);
 
     /* Fill acl types */
-    $this->aclTypes= array( "reset" => _("Reset ACL"),
-                             "one" => _("One level"),
-                             "base" => _("Current object"),
-                             "sub" => _("Complete subtree"),
-                             "psub" => _("Complete subtree (permanent)"));
+    $this->aclTypes = array( "reset" => _("Reset ACL"),
+                              "one" => _("One level"),
+                              "base" => _("Current object"),
+                              "sub" => _("Complete subtree"),
+                              "psub" => _("Complete subtree (permanent)"));
     asort($this->aclTypes);
 
     /* Finally - we want to get saved... */
-    $this->is_account= TRUE;
-    $this->orig_base = $this->base;
-    $this->orig_dn = $this->dn;
-    $this->orig_cn = $this->cn;
+    $this->is_account = TRUE;
+    $this->orig_base  = $this->base;
+    $this->orig_dn    = $this->dn;
+    $this->orig_cn    = $this->cn;
 
     /* Instanciate base selector */
-    $this->baseSelector= new baseSelector($this->get_allowed_bases(), $this->base);
-    $this->baseSelector->setSubmitButton(false);
+    $this->baseSelector = new baseSelector($this->get_allowed_bases(), $this->base);
+    $this->baseSelector->setSubmitButton(FALSE);
     $this->baseSelector->setHeight(300);
-    $this->baseSelector->update(true);
+    $this->baseSelector->update(TRUE);
   }
 
 
@@ -99,65 +99,66 @@ class aclrole extends acl
     /* Call parent execute */
     plugin::execute();
 
-    $tmp= session::get('plist');
-    $plist= $tmp->info;
+    $tmp    = session::get('plist');
+    $plist  = $tmp->info;
 
     /* Handle posts */
-    if (isset($_POST['new_acl']) && $this->acl_is_writeable("gosaAclEntry")){
-      $this->dialogState= 'create';
-      $this->dialog= TRUE;
-      $this->currentIndex= count($this->gosaAclTemplate);
+    if (isset($_POST['new_acl']) && $this->acl_is_writeable("gosaAclEntry")) {
+      $this->dialogState  = 'create';
+      $this->dialog       = TRUE;
+      $this->currentIndex = count($this->gosaAclTemplate);
       $this->loadAclEntry(TRUE);
     }
 
-    $new_acl= array();
-    $aclDialog= FALSE;
-    $firstedit= FALSE;
+    $new_acl    = array();
+    $aclDialog  = FALSE;
+    $firstedit  = FALSE;
 
     /* Act on HTML post and gets here.
      */
-    if(isset($_GET['id']) && isset($_GET['act']) && $_GET['act'] == "edit"){
+    if (isset($_GET['id']) && isset($_GET['act']) && $_GET['act'] == "edit") {
       $id = trim($_GET['id']);
-      $this->dialogState= 'create';
-      $firstedit= TRUE;
-      $this->dialog= TRUE;
-      $this->currentIndex= $id;
+
+      $this->dialogState  = 'create';
+      $firstedit          = TRUE;
+      $this->dialog       = TRUE;
+      $this->currentIndex = $id;
       $this->loadAclEntry();
     }
 
-    foreach($_POST as $name => $post){
+    foreach ($_POST as $name => $post) {
 
       /* Actions... */
-      if (preg_match('/^acl_edit_.*_x/', $name)){
-        $this->dialogState= 'create';
-        $firstedit= TRUE;
-        $this->dialog= TRUE;
-        $this->currentIndex= preg_replace('/^acl_edit_([0-9]+).*$/', '\1', $name);
+      if (preg_match('/^acl_edit_.*_x/', $name)) {
+        $this->dialogState  = 'create';
+        $firstedit          = TRUE;
+        $this->dialog       = TRUE;
+        $this->currentIndex = preg_replace('/^acl_edit_([0-9]+).*$/', '\1', $name);
         $this->loadAclEntry();
         continue;
       }
-      if (preg_match('/^cat_edit_.*_x/', $name)){
-        $this->aclObject= preg_replace('/^cat_edit_([^_]+)_.*$/', '\1', $name);
-        $this->dialogState= 'edit';
+      if (preg_match('/^cat_edit_.*_x/', $name)) {
+        $this->aclObject    = preg_replace('/^cat_edit_([^_]+)_.*$/', '\1', $name);
+        $this->dialogState  = 'edit';
         foreach ($this->config->data['CATEGORIES'][$this->aclObject]['classes'] as $oc) {
-          if (isset($this->aclContents[$oc])){
-            $this->savedAclContents[$oc]= $this->aclContents[$oc];
+          if (isset($this->aclContents[$oc])) {
+            $this->savedAclContents[$oc] = $this->aclContents[$oc];
           }
         }
         continue;
       }
 
-      if(!$this->acl_is_writeable("gosaAclEntry")){
+      if (!$this->acl_is_writeable("gosaAclEntry")) {
         continue;
       }
 
-      if (preg_match('/^acl_del_.*_x/', $name) && $this->acl_is_writeable("gosaAclEntry")){
+      if (preg_match('/^acl_del_.*_x/', $name) && $this->acl_is_writeable("gosaAclEntry")) {
         unset($this->gosaAclTemplate[preg_replace('/^acl_del_([0-9]+).*$/', '\1', $name)]);
         continue;
       }
 
-      if (preg_match('/^cat_del_.*_x/', $name) && $this->acl_is_writeable("gosaAclEntry")){
-        $idx= preg_replace('/^cat_del_([^_]+)_.*$/', '\1', $name);
+      if (preg_match('/^cat_del_.*_x/', $name) && $this->acl_is_writeable("gosaAclEntry")) {
+        $idx = preg_replace('/^cat_del_([^_]+)_.*$/', '\1', $name);
         foreach ($this->config->data['CATEGORIES'][$idx]['classes'] as $key) {
           unset($this->aclContents["$idx/$key"]);
         }
@@ -165,21 +166,23 @@ class aclrole extends acl
       }
 
       /* Sorting... */
-      if (preg_match('/^sortup_.*_x/', $name) && $this->acl_is_writeable("gosaAclEntry")){
-        $index= preg_replace('/^sortup_([0-9]+).*$/', '\1', $name);
-        if ($index > 0){
-          $tmp= $this->gosaAclTemplate[$index];
-          $this->gosaAclTemplate[$index]= $this->gosaAclTemplate[$index-1];
-          $this->gosaAclTemplate[$index-1]= $tmp;
+      if (preg_match('/^sortup_.*_x/', $name) && $this->acl_is_writeable("gosaAclEntry")) {
+        $index = preg_replace('/^sortup_([0-9]+).*$/', '\1', $name);
+        if ($index > 0) {
+          $tmp = $this->gosaAclTemplate[$index];
+
+          $this->gosaAclTemplate[$index]      = $this->gosaAclTemplate[$index - 1];
+          $this->gosaAclTemplate[$index - 1]  = $tmp;
         }
         continue;
       }
-      if (preg_match('/^sortdown_.*_x/', $name) && $this->acl_is_writeable("gosaAclEntry")){
-        $index= preg_replace('/^sortdown_([0-9]+).*$/', '\1', $name);
-        if ($index < count($this->gosaAclTemplate)-1){
-          $tmp= $this->gosaAclTemplate[$index];
-          $this->gosaAclTemplate[$index]= $this->gosaAclTemplate[$index+1];
-          $this->gosaAclTemplate[$index+1]= $tmp;
+      if (preg_match('/^sortdown_.*_x/', $name) && $this->acl_is_writeable("gosaAclEntry")) {
+        $index = preg_replace('/^sortdown_([0-9]+).*$/', '\1', $name);
+        if ($index < count($this->gosaAclTemplate) - 1) {
+          $tmp = $this->gosaAclTemplate[$index];
+
+          $this->gosaAclTemplate[$index]      = $this->gosaAclTemplate[$index + 1];
+          $this->gosaAclTemplate[$index + 1]  = $tmp;
         }
         continue;
       }
@@ -196,19 +199,19 @@ class aclrole extends acl
         }
 
         /* Ordinary ACL */
-        if (!isset($new_acl[$object])){
-          $new_acl[$object]= array();
+        if (!isset($new_acl[$object])) {
+          $new_acl[$object] = array();
         }
-        if (isset($new_acl[$object][$attribute])){
-          $new_acl[$object][$attribute].= $value;
+        if (isset($new_acl[$object][$attribute])) {
+          $new_acl[$object][$attribute] .= $value;
         } else {
-          $new_acl[$object][$attribute]= $value;
+          $new_acl[$object][$attribute] = $value;
         }
       }
     }
 
-    if(isset($_POST['acl_dummy_0_0_0'])){
-      $aclDialog= TRUE;
+    if (isset($_POST['acl_dummy_0_0_0'])) {
+      $aclDialog = TRUE;
     }
 
     /* Only be interested in new acl's, if we're in the right _POST place */
@@ -217,166 +220,167 @@ class aclrole extends acl
       foreach ($this->config->data['CATEGORIES'][$this->aclObject]['classes'] as $oc) {
         unset($this->aclContents[$oc]);
         unset($this->aclContents[$this->aclObject.'/'.$oc]);
-        if (isset($new_acl[$oc])){
-          $this->aclContents[$oc]= $new_acl[$oc];
+        if (isset($new_acl[$oc])) {
+          $this->aclContents[$oc] = $new_acl[$oc];
         }
-        if (isset($new_acl[$this->aclObject.'/'.$oc])){
-          $this->aclContents[$this->aclObject.'/'.$oc]= $new_acl[$this->aclObject.'/'.$oc];
+        if (isset($new_acl[$this->aclObject.'/'.$oc])) {
+          $this->aclContents[$this->aclObject.'/'.$oc] = $new_acl[$this->aclObject.'/'.$oc];
         }
       }
     }
 
     /* Save new acl in case of base edit mode */
-    if (1 == 0 && $this->aclType == 'base' && !$firstedit){
-      $this->aclContents= $new_acl;
+    if (1 == 0 && $this->aclType == 'base' && !$firstedit) {
+      $this->aclContents = $new_acl;
     }
 
     /* Cancel new acl? */
-    if (isset($_POST['cancel_new_acl'])){
-      $this->dialogState= 'head';
-      $this->dialog= FALSE;
-      if ($this->wasNewEntry){
-        unset ($this->gosaAclTemplate[$this->currentIndex]);
+    if (isset($_POST['cancel_new_acl'])) {
+      $this->dialogState  = 'head';
+      $this->dialog       = FALSE;
+      if ($this->wasNewEntry) {
+        unset($this->gosaAclTemplate[$this->currentIndex]);
       }
     }
 
     /* Store ACL in main object? */
-    if (isset($_POST['submit_new_acl']) && $this->acl_is_writeable("gosaAclEntry")){
-      $this->gosaAclTemplate[$this->currentIndex]['type']= $this->aclType;
-      $this->gosaAclTemplate[$this->currentIndex]['members']= $this->recipients;
-      $this->gosaAclTemplate[$this->currentIndex]['acl']= $this->aclContents;
-      $this->dialogState= 'head';
-      $this->dialog= FALSE;
+    if (isset($_POST['submit_new_acl']) && $this->acl_is_writeable("gosaAclEntry")) {
+      $this->gosaAclTemplate[$this->currentIndex]['type']     = $this->aclType;
+      $this->gosaAclTemplate[$this->currentIndex]['members']  = $this->recipients;
+      $this->gosaAclTemplate[$this->currentIndex]['acl']      = $this->aclContents;
+
+      $this->dialogState  = 'head';
+      $this->dialog       = FALSE;
     }
 
     /* Cancel edit acl? */
-    if (isset($_POST['cancel_edit_acl'])){
-      $this->dialogState= 'create';
+    if (isset($_POST['cancel_edit_acl'])) {
+      $this->dialogState = 'create';
       foreach ($this->config->data['CATEGORIES'][$this->aclObject]['classes'] as $oc) {
-        if (isset($this->savedAclContents[$oc])){
-          $this->aclContents[$oc]= $this->savedAclContents[$oc];
+        if (isset($this->savedAclContents[$oc])) {
+          $this->aclContents[$oc] = $this->savedAclContents[$oc];
         }
       }
     }
 
     /* Save edit acl? */
-    if (isset($_POST['submit_edit_acl']) && $this->acl_is_writeable("gosaAclEntry")){
-      $this->dialogState= 'create';
+    if (isset($_POST['submit_edit_acl']) && $this->acl_is_writeable("gosaAclEntry")) {
+      $this->dialogState = 'create';
     }
 
     /* Add acl? */
-    if (isset($_POST['add_acl']) && $_POST['aclObject'] != "" && $this->acl_is_writeable("gosaAclEntry")){
-      $this->dialogState= 'edit';
-      $this->savedAclContents= array();
+    if (isset($_POST['add_acl']) && $_POST['aclObject'] != "" && $this->acl_is_writeable("gosaAclEntry")) {
+      $this->dialogState      = 'edit';
+      $this->savedAclContents = array();
       foreach ($this->config->data['CATEGORIES'][$this->aclObject]['classes'] as $oc) {
-        if (isset($this->aclContents[$oc])){
-          $this->savedAclContents[$oc]= $this->aclContents[$oc];
+        if (isset($this->aclContents[$oc])) {
+          $this->savedAclContents[$oc] = $this->aclContents[$oc];
         }
       }
     }
 
     /* Save common values */
-    foreach (array("aclType", "aclObject", "target") as $key){
-      if (isset($_POST[$key]) && $this->acl_is_writeable("gosaAclEntry")){
-        $this->$key= validate($_POST[$key]);
+    foreach (array("aclType", "aclObject", "target") as $key) {
+      if (isset($_POST[$key]) && $this->acl_is_writeable("gosaAclEntry")) {
+        $this->$key = validate($_POST[$key]);
       }
     }
 
     /* Create templating instance */
-    $smarty= get_smarty();
+    $smarty = get_smarty();
     $smarty->assign("usePrototype", "true");
 
     $smarty->assign("base", $this->baseSelector->render());
 
     $tmp = $this->plInfo();
-    foreach($tmp['plProvidedAcls'] as $name => $translation){
-      $smarty->assign($name."ACL",$this->getacl($name));
+    foreach ($tmp['plProvidedAcls'] as $name => $translation) {
+      $smarty->assign($name."ACL", $this->getacl($name));
     }
 
-    if ($this->dialogState == 'head'){
+    if ($this->dialogState == 'head') {
       /* Draw list */
-      $aclList= new divSelectBox("aclList");
+      $aclList = new divSelectBox("aclList");
       $aclList->SetHeight(350);
 
       /* Fill in entries */
-      foreach ($this->gosaAclTemplate as $key => $entry){
+      foreach ($this->gosaAclTemplate as $key => $entry) {
 
-        if($this->acl_is_readable("")){
+        if ($this->acl_is_readable("")) {
           $link = "<a href=?plug=".$_GET['plug']."&amp;id=".$key."&amp;act=edit>".$this->assembleAclSummary($entry)."</a>";
-        }else{
+        } else {
           $link = $this->assembleAclSummary($entry);
         }
 
-        $field1= array("html" => $this->aclTypes[$entry['type']], "attach" => "style='width:150px'");
-        $field2= array("html" => $link);
+        $field1 = array("html" => $this->aclTypes[$entry['type']], "attach" => "style='width:150px'");
+        $field2 = array("html" => $link);
 
-        $action ="";
-        if($this->acl_is_writeable("gosaAclEntry")){
-          $action.= "<input type='image' name='sortup_$key' alt='up'
+        $action = "";
+        if ($this->acl_is_writeable("gosaAclEntry")) {
+          $action .= "<input type='image' name='sortup_$key' alt='up'
             title='"._("Up")."' src='images/lists/sort-up.png' align='top'>";
-          $action.= "<input type='image' name='sortdown_$key' alt='down'
+          $action .= "<input type='image' name='sortdown_$key' alt='down'
             title='"._("Down")."' src='images/lists/sort-down.png'>";
         }
-        if($this->acl_is_readable("gosaAclEntry")){
-          $action.= "<input class='center' type='image' src='images/lists/edit.png' alt='"._("Edit")."' name='acl_edit_$key'
+        if ($this->acl_is_readable("gosaAclEntry")) {
+          $action .= "<input class='center' type='image' src='images/lists/edit.png' alt='"._("Edit")."' name='acl_edit_$key'
             title='".msgPool::editButton(_("ACL"))."'>";
         }
-        if($this->acl_is_writeable("gosaAclEntry")){
-          $action.= "<input class='center' type='image' src='images/lists/trash.png' alt='"._("Delete")."' name='acl_del_$key'
+        if ($this->acl_is_writeable("gosaAclEntry")) {
+          $action .= "<input class='center' type='image' src='images/lists/trash.png' alt='"._("Delete")."' name='acl_del_$key'
             title='".msgPool::delButton(_("ACL"))."'>";
         }
 
-        $field3= array("html" => $action, "attach" => "style='border-right:0px;width:50px;text-align:right;'");
+        $field3 = array("html" => $action, "attach" => "style='border-right:0px;width:50px;text-align:right;'");
         $aclList->AddEntry(array($field1, $field2, $field3));
       }
 
       $smarty->assign("aclList", $aclList->DrawList());
     }
 
-    if ($this->dialogState == 'create'){
+    if ($this->dialogState == 'create') {
       /* Draw list */
-      $aclList= new divSelectBox("aclList");
+      $aclList = new divSelectBox("aclList");
       $aclList->SetHeight(450);
 
       /* Add settings for all categories to the (permanent) list */
       foreach ($this->config->data['CATEGORIES'] as $section => $infos) {
         $summary = "";
-        foreach($infos['classes'] as $oc) {
+        foreach ($infos['classes'] as $oc) {
           if (isset($this->aclContents[$oc]) && count($this->aclContents[$oc]) && isset($this->aclContents[$oc][0]) &&
-              $this->aclContents[$oc][0] != ""){
+              $this->aclContents[$oc][0] != "") {
 
-            $summary.= "$oc, ";
+            $summary .= "$oc, ";
             continue;
           }
-          if (isset($this->aclContents["$section/$oc"]) && count($this->aclContents["$section/$oc"])){
-            $summary.= "$oc, ";
+          if (isset($this->aclContents["$section/$oc"]) && count($this->aclContents["$section/$oc"])) {
+            $summary .= "$oc, ";
             continue;
           }
-          if (isset($this->aclContents[$oc]) && !isset($this->aclContents[$oc][0]) && count($this->aclContents[$oc])){
-            $summary.= "$oc, ";
+          if (isset($this->aclContents[$oc]) && !isset($this->aclContents[$oc][0]) && count($this->aclContents[$oc])) {
+            $summary .= "$oc, ";
           }
         }
 
         /* Set summary... */
-        if ($summary == ""){
-          $summary= '<i>'._("No ACL settings for this category").'</i>';
+        if ($summary == "") {
+          $summary = '<i>'._("No ACL settings for this category").'</i>';
         } else {
-          $summary= sprintf(_("ACL for these objects: %s"), preg_replace('/, $/', '', $summary));
+          $summary = sprintf(_("ACL for these objects: %s"), preg_replace('/, $/', '', $summary));
         }
 
         $action = "";
-        if($this->acl_is_readable("gosaAclEntry")){
-          $action.= "<input class='center' type='image' src='images/lists/edit.png'
+        if ($this->acl_is_readable("gosaAclEntry")) {
+          $action .= "<input class='center' type='image' src='images/lists/edit.png'
             alt='"._("Edit")."' name='cat_edit_$section'   title='"._("Edit category ACL")."'>";
         }
-        if($this->acl_is_writeable("gosaAclEntry")){
-          $action.= "<input class='center' type='image' src='images/lists/trash.png'
+        if ($this->acl_is_writeable("gosaAclEntry")) {
+          $action .= "<input class='center' type='image' src='images/lists/trash.png'
             alt='"._("Delete")."' name='cat_del_$section' title='"._("Reset category ACL")."'>";
         }
 
-        $field1= array("html" => $infos['description'], "attach" => "style='width:140px'");
-        $field2= array("html" => $summary);
-        $field3= array("html" => $action, "attach" => "style='border-right:0px;width:50px'");
+        $field1 = array("html" => $infos['description'], "attach" => "style='width:140px'");
+        $field2 = array("html" => $summary);
+        $field3 = array("html" => $action, "attach" => "style='border-right:0px;width:50px'");
         $aclList->AddEntry(array($field1, $field2, $field3));
       }
 
@@ -385,23 +389,23 @@ class aclrole extends acl
       $smarty->assign("aclTypes", $this->aclTypes);
       $smarty->assign("target", $this->target);
 
-      if ($this->aclType == 'base'){
+      if ($this->aclType == 'base') {
         $smarty->assign('aclSelector', $this->buildAclSelector(array()));
       }
     }
 
-    if ($this->dialogState == 'edit'){
+    if ($this->dialogState == 'edit') {
       $smarty->assign('headline', sprintf(_("Edit ACL for '%s', scope is '%s'"), $this->config->data['CATEGORIES'][$this->aclObject]['description'], $this->aclTypes[$this->aclType]));
 
       /* Collect objects for selected category */
       foreach ($this->config->data['CATEGORIES'][$this->aclObject]['classes'] as $idx => $class) {
-        if ($idx == 0){
+        if ($idx == 0) {
           continue;
         }
-        $aclObjects[$this->aclObject.'/'.$class]= $plist[$class]['plDescription'];
+        $aclObjects[$this->aclObject.'/'.$class] = $plist[$class]['plDescription'];
       }
-      if ($this->aclObject == 'all'){
-        $aclObjects['all']= _("All objects in current subtree");
+      if ($this->aclObject == 'all') {
+        $aclObjects['all'] = _("All objects in current subtree");
       }
       $smarty->assign('aclSelector', $this->buildAclSelector($aclObjects));
     }
@@ -410,25 +414,25 @@ class aclrole extends acl
     $smarty->assign("dialogState", $this->dialogState);
 
     /* Assign cn and decription if this is a role */
-    foreach(array("cn","description") as $name){
-      $smarty->assign($name,$this->$name);
+    foreach (array("cn","description") as $name) {
+      $smarty->assign($name, $this->$name);
     }
-    return ($smarty->fetch (get_template_path('acl_role.tpl',dirname(__FILE__))));
+    return $smarty->fetch(get_template_path('acl_role.tpl', dirname(__FILE__)));
   }
 
   function sort_by_priority($list)
   {
-    $tmp= session::get('plist');
-    $plist= $tmp->info;
+    $tmp    = session::get('plist');
+    $plist  = $tmp->info;
     asort($plist);
     $newSort = array();
 
-    foreach($list as $name => $translation){
-      $na  =  preg_replace("/^.*\//","",$name);
-      if (!isset($plist[$na]['plPriority'])){
-        $prio= 0;
+    foreach ($list as $name => $translation) {
+      $na = preg_replace("/^.*\//", "", $name);
+      if (!isset($plist[$na]['plPriority'])) {
+        $prio = 0;
       } else {
-        $prio=  $plist[$na]['plPriority'] ;
+        $prio = $plist[$na]['plPriority'];
       }
 
       $newSort[$name] = $prio;
@@ -437,33 +441,34 @@ class aclrole extends acl
     asort($newSort);
 
     $ret = array();
-    foreach($newSort as $name => $prio){
+    foreach ($newSort as $name => $prio) {
       $ret[$name] = $list[$name];
     }
-    return($ret);
+    return $ret;
   }
 
-  function loadAclEntry($new= FALSE)
+  function loadAclEntry($new = FALSE)
   {
     /* New entry gets presets... */
-    if ($new){
-      $this->aclType= 'sub';
-      $this->recipients= array();
-      $this->aclContents= array();
+    if ($new) {
+      $this->aclType      = 'sub';
+      $this->recipients   = array();
+      $this->aclContents  = array();
     } else {
-      $acl= $this->gosaAclTemplate[$this->currentIndex];
-      $this->aclType= $acl['type'];
-      $this->recipients= $acl['members'];
-      $this->aclContents= $acl['acl'];
+      $acl = $this->gosaAclTemplate[$this->currentIndex];
+
+      $this->aclType      = $acl['type'];
+      $this->recipients   = $acl['members'];
+      $this->aclContents  = $acl['acl'];
     }
 
-    $this->wasNewEntry= $new;
+    $this->wasNewEntry = $new;
   }
 
 
   function aclPostHandler()
   {
-    if (isset($_POST['save_acl']) && $this->acl_is_writeable("gosaAclEntry")){
+    if (isset($_POST['save_acl']) && $this->acl_is_writeable("gosaAclEntry")) {
       $this->save();
       return TRUE;
     }
@@ -475,115 +480,116 @@ class aclrole extends acl
   function save()
   {
     /* Assemble ACL's */
-    $tmp_acl= array();
-    foreach ($this->gosaAclTemplate as $prio => $entry){
-      $final= "";
-      $members= "";
-      if (isset($entry['members'])){
-        foreach ($entry['members'] as $key => $dummy){
-          $members.= base64_encode(preg_replace('/^.:/', '', $key)).',';
+    $tmp_acl = array();
+    foreach ($this->gosaAclTemplate as $prio => $entry) {
+      $final    = "";
+      $members  = "";
+      if (isset($entry['members'])) {
+        foreach ($entry['members'] as $key => $dummy) {
+          $members .= base64_encode(preg_replace('/^.:/', '', $key)).',';
         }
       }
-      $final= $prio.":".$entry['type'].":".preg_replace('/,$/', '', $members);
+      $final = $prio.":".$entry['type'].":".preg_replace('/,$/', '', $members);
 
       /* ACL's if needed */
-      if ($entry['type'] != "reset" && $entry['type'] != "role"){
-        $acl= ":";
-        if (isset($entry['acl'])){
-          foreach ($entry['acl'] as $object => $contents){
+      if ($entry['type'] != "reset" && $entry['type'] != "role") {
+        $acl = ":";
+        if (isset($entry['acl'])) {
+          foreach ($entry['acl'] as $object => $contents) {
 
             /* Only save, if we've some contents in there... */
-            if (count($contents)){
-              $acl.= $object.";";
+            if (count($contents)) {
+              $acl .= $object.";";
 
-              foreach($contents as $attr => $permission){
+              foreach ($contents as $attr => $permission) {
 
                 /* First entry? Its the one for global settings... */
-                if ($attr == '0'){
-                  $acl.= $permission;
+                if ($attr == '0') {
+                  $acl .= $permission;
                 } else {
-                  $acl.= '#'.$attr.';'.$permission;
+                  $acl .= '#'.$attr.';'.$permission;
                 }
 
               }
-              $acl.= ',';
+              $acl .= ',';
             }
 
           }
         }
-        $final.= preg_replace('/,$/', '', $acl);
+        $final .= preg_replace('/,$/', '', $acl);
       }
 
-      $tmp_acl[]= $final;
+      $tmp_acl[] = $final;
     }
 
     /* Call main method */
     plugin::save();
 
     /* Finally (re-)assign it... */
-    $this->attrs["gosaAclTemplate"]= $tmp_acl;
+    $this->attrs["gosaAclTemplate"] = $tmp_acl;
 
     /* Remove acl from this entry if it is empty... */
-    if (!count($tmp_acl)){
+    if (!count($tmp_acl)) {
       /* Remove attribute */
-      if ($this->initially_was_account){
-        $this->attrs["gosaAclTempalte"]= array();
+      if ($this->initially_was_account) {
+        $this->attrs["gosaAclTempalte"] = array();
       } else {
-        if (isset($this->attrs["gosaAclTemplate"])){
+        if (isset($this->attrs["gosaAclTemplate"])) {
           unset($this->attrs["gosaAclTemplate"]);
         }
       }
     }
 
     /* Do LDAP modifications */
-    $ldap= $this->config->get_ldap_link();
+    $ldap = $this->config->get_ldap_link();
 
     /* Check if object already exists */
     $ldap->cat($this->dn);
-    if($ldap->count()){
+    if ($ldap->count()) {
       $ldap->cd($this->dn);
       $this->cleanup();
       $ldap->modify ($this->attrs);
-      new log("modify","acl/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    }else{
+      new log("modify", "acl/".get_class($this), $this->dn, array_keys($this->attrs), $ldap->get_error());
+    } else {
       $ldap->cd($this->config->current['BASE']);
-      $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$this->dn));
+      $ldap->create_missing_trees(preg_replace("/^[^,]+,/", "", $this->dn));
       $ldap->cd($this->dn);
       $ldap->add($this->attrs);
-      new log("create","acl/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+      new log("create", "acl/".get_class($this), $this->dn, array_keys($this->attrs), $ldap->get_error());
     }
 
-    if (!$ldap->success()){
+    if (!$ldap->success()) {
       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, "", get_class()));
     }
 
     /* Refresh users ACL */
-    $ui= get_userinfo();
+    $ui = get_userinfo();
     $ui->loadACL();
-    session::set('ui',$ui);
+    session::set('ui', $ui);
   }
 
 
   function remove_from_parent()
   {
-    $ldap = $this->config->get_ldap_link();
+    $ldap       = $this->config->get_ldap_link();
     $serach_for = "*:role:".base64_encode($this->dn).":*";
-    $ldap->search ("(&(objectClass=gosaACL)(gosaAclEntry=".$serach_for."))",array('dn','cn','sn','givenName','uid'));
+    $ldap->search("(&(objectClass=gosaACL)(gosaAclEntry=".$serach_for."))", array('dn','cn','sn','givenName','uid'));
     $all_names = "";
 
 
     $cnt = 3;
-    while(($attrs = $ldap->fetch()) && $cnt){
+    while (($attrs = $ldap->fetch()) && $cnt) {
       $name = $attrs['dn'];
-      $name = preg_replace("/[ ]/","&nbsp;",$name);
+      $name = preg_replace("/[ ]/", "&nbsp;", $name);
       $name = "<i>'".$name."'</i>";
+
       $all_names .= $name.", ";
-      $cnt --;
+      $cnt--;
     }
 
-    if(!empty($all_names)){
-      $all_names = preg_replace("/, $/","",$all_names);
-      if(!$cnt){
+    if (!empty($all_names)) {
+      $all_names = preg_replace("/, $/", "", $all_names);
+      if (!$cnt) {
         $all_names .= ", ...";
       }
       $all_names = "<span style='text-align:left;'>".$all_names."</span>";
@@ -592,8 +598,8 @@ class aclrole extends acl
     }
 
     $ldap->rmDir($this->dn);
-    new log("remove","acl/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    if (!$ldap->success()){
+    new log("remove", "acl/".get_class($this), $this->dn, array_keys($this->attrs), $ldap->get_error());
+    if (!$ldap->success()) {
       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, "", get_class()));
     }
 
@@ -603,11 +609,11 @@ class aclrole extends acl
     /* Delete references to object groups */
     $ldap->cd ($this->config->current['BASE']);
     $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
-    while ($ldap->fetch()){
-      $og= new ogroup($this->config, $ldap->getDN());
+    while ($ldap->fetch()) {
+      $og = new ogroup($this->config, $ldap->getDN());
       unset($og->member[$this->dn]);
       $og->save ();
-      if (!$ldap->success()){
+      if (!$ldap->success()) {
         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $og->dn, "", get_class()));
       }
     }
@@ -617,16 +623,16 @@ class aclrole extends acl
   function save_object()
   {
     plugin::save_object();
-    if(isset($_POST['acl_role_posted'])){
+    if (isset($_POST['acl_role_posted'])) {
 
       /* Refresh base */
-      if ($this->acl_is_moveable($this->base)){
+      if ($this->acl_is_moveable($this->base)) {
         if (!$this->baseSelector->update()) {
           msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
         }
         if ($this->base != $this->baseSelector->getBase()) {
-          $this->base= $this->baseSelector->getBase();
-          $this->is_modified= TRUE;
+          $this->base         = $this->baseSelector->getBase();
+          $this->is_modified  = TRUE;
         }
       }
     }
@@ -659,44 +665,43 @@ class aclrole extends acl
   {
     $message = plugin::check();
 
-    if(empty($this->cn)){
+    if (empty($this->cn)) {
       $message[] = msgPool::required(_("Name"));
     }
 
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->config->current['BASE']);
-    if($this->cn != $this->orig_cn){
+    if ($this->cn != $this->orig_cn) {
       $ldap->search("(&(objectClass=gosaRole)(cn=".$this->cn."))");
-      if($ldap->count()) {
-        while($attrs = $ldap->fetch()){
-          if($attrs['dn'] != $this->orig_dn){
+      if ($ldap->count()) {
+        while ($attrs = $ldap->fetch()) {
+          if ($attrs['dn'] != $this->orig_dn) {
             $message[] = msgPool::duplicated(_("Name"));
           }
         }
       }
     }
 
-    if(!count($this->gosaAclTemplate)){
+    if (!count($this->gosaAclTemplate)) {
       $message[] = msgPool::required(_("ACL"));
     }
 
     // Check if a wrong base was supplied
-    if(!$this->baseSelector->checkLastBaseUpdate()){
-      $message[]= msgPool::check_base();;
+    if (!$this->baseSelector->checkLastBaseUpdate()) {
+      $message[] = msgPool::check_base();;
     }
 
     /* Check if we are allowed to create or move this object
      */
-    if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
+    if ($this->orig_dn == "new" && !$this->acl_is_createable($this->base)) {
       $message[] = msgPool::permCreate();
-    }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
+    } elseif ($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)) {
       $message[] = msgPool::permMove();
     }
 
-    return($message);
+    return $message;
   }
 
 }
 
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
diff --git a/setup/class_setup.inc b/setup/class_setup.inc
index eb5e62bcd44a7ca1067a497d277be4d3861481a4..52dce8f4e6d709aa96b3ad7f2e92e6d3b45cf5e4 100644
--- a/setup/class_setup.inc
+++ b/setup/class_setup.inc
@@ -31,7 +31,7 @@ class setup
   var $o_steps          = array();
   var $captured_values  = array();
 
-  function setup()
+  function __construct()
   {
     $i = 1;
     $this->o_steps[$i++] = new Step_Welcome();
diff --git a/setup/class_setupStep_Checks.inc b/setup/class_setupStep_Checks.inc
index d0bd4c0bbd227e318b76566b075c55ae13e49e92..e60c6922aed9ac37199a391fe047eb40fc191360 100644
--- a/setup/class_setupStep_Checks.inc
+++ b/setup/class_setupStep_Checks.inc
@@ -22,12 +22,12 @@
 
 class Step_Checks extends setup_step
 {
-  var $basic_checks = array();
-  var $config_checks= array();
-  var $is_writeable = array();
-  var $header_image = "images/setup/system.png";
+  var $basic_checks   = array();
+  var $config_checks  = array();
+  var $is_writeable   = array();
+  var $header_image   = "images/setup/system.png";
 
-  function Step_Checks()
+  function __construct()
   {
     $this->update_strings();
   }
@@ -46,10 +46,10 @@ class Step_Checks extends setup_step
   {
     $this->run_checks();
     $smarty = get_smarty();
-    $smarty->assign("basic"       ,$this->basic_checks);
-    $smarty->assign("config"      ,$this->config_checks);
-    $smarty->assign("is_writeable",$this->is_writeable);
-    return($smarty->fetch(get_template_path("setup_checks.tpl",TRUE,dirname(__FILE__))));
+    $smarty->assign("basic",        $this->basic_checks);
+    $smarty->assign("config",       $this->config_checks);
+    $smarty->assign("is_writeable", $this->is_writeable);
+    return $smarty->fetch(get_template_path("setup_checks.tpl", TRUE, dirname(__FILE__)));
   }
 
 
@@ -142,9 +142,8 @@ class Step_Checks extends setup_step
     $IMGVER = phpversion('imagick');
 
     if ($IMGVER > 1.0) {
-        $R = method_exists('imagick','getImageBlob');
-    }
-    else {
+        $R = method_exists('imagick', 'getImageBlob');
+    } else {
         $R = is_callable("imagick_blob2image") || !empty($output);
     }
 
@@ -208,7 +207,7 @@ class Step_Checks extends setup_step
     $N = "max_execution_time &gt;= <b>30</b>";
     $D = _("The Execution time should be at least 30 seconds.");
     $S = _("Search for 'max_execution_time' in your php.ini and set it to '30' or higher.");
-    $R = ini_get("max_execution_time") >= 30 ;
+    $R = ini_get("max_execution_time") >= 30;
     $M = TRUE;
     $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M );
 
@@ -235,10 +234,10 @@ class Step_Checks extends setup_step
     /* Check if we can create a config file.*/
     $N = _("Configuration writeable");
     $D = _("The configuration file can't be written");
-    $S = sprintf(_("FusionDirectory reads its configuration from a file located in (%s/%s). The setup can write the configuration directly if it is writeable."),CONFIG_DIR,CONFIG_FILE);
+    $S = sprintf(_("FusionDirectory reads its configuration from a file located in (%s/%s). The setup can write the configuration directly if it is writeable."), CONFIG_DIR, CONFIG_FILE);
     /* is there a config file ? or There is none, but can we create a file there ?*/
-    $R =    ( file_exists(CONFIG_DIR."/".CONFIG_FILE) && is_writeable(CONFIG_DIR."/".CONFIG_FILE))
-        ||  (!file_exists(CONFIG_DIR."/".CONFIG_FILE) && is_writeable(CONFIG_DIR));
+    $R = ( file_exists(CONFIG_DIR."/".CONFIG_FILE) && is_writeable(CONFIG_DIR."/".CONFIG_FILE))
+          || (!file_exists(CONFIG_DIR."/".CONFIG_FILE) && is_writeable(CONFIG_DIR));
     $M = FALSE;
     $this->is_writeable[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M );
 
@@ -248,14 +247,12 @@ class Step_Checks extends setup_step
   function save_object()
   {
      /* If everything is fine, set this step to completed
-     *  and allow switching to next setup step
-     */
-    $failed = false;
-    foreach(array("basic_checks","config_checks","is_writeable") as $type){
-      foreach($this->$type as $obj){
-
-        if($obj['MUST'] && !$obj['RESULT']){
-          $failed = true;
+     *  and allow switching to next setup step */
+    $failed = FALSE;
+    foreach (array("basic_checks","config_checks","is_writeable") as $type) {
+      foreach ($this->$type as $obj) {
+        if ($obj['MUST'] && !$obj['RESULT']) {
+          $failed = TRUE;
           break;
         }
       }
@@ -268,9 +265,8 @@ class Step_Checks extends setup_step
       with the current version of FusionDirectory */
   function check_php_version()
   {
-    return(version_compare(phpversion(),"5.2.0",">="));
+    return version_compare(phpversion(), "5.2.0", ">=");
   }
 }
 
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
diff --git a/setup/class_setupStep_Config1.inc b/setup/class_setupStep_Config1.inc
index e33af366cfdde6af8805c607bdd7ba24e09d961d..f883b69ab67b65b3b978e62174757fe99d5b1a49 100644
--- a/setup/class_setupStep_Config1.inc
+++ b/setup/class_setupStep_Config1.inc
@@ -60,7 +60,7 @@ class Step_Config1 extends setup_step
                           "base_hook","base_hook_active","account_expiration","strict","include_personal_title",
                           "cngen_active","cngen");
 
-  function Step_Config1()
+  function __construct()
   {
     $this->update_strings();
 
@@ -214,14 +214,7 @@ class Step_Config1 extends setup_step
       }
 
       /* base hook settings */
-/*      if (isset($_POST['base_hook_active'])) {
-        $this->pwd_rules['base_hook_active'] = TRUE;
-        if (isset($_POST['base_hook'])) {
-          $this->pwd_rules['base_hook'] = get_post('base_hook');
-        }
-      } else {*/
-        $this->pwd_rules['base_hook_active'] = FALSE;
-/*      }*/
+      $this->pwd_rules['base_hook_active'] = FALSE;
 
       if (isset($_POST['cngen_active'])) {
         $this->cngen_active = TRUE;
diff --git a/setup/class_setupStep_Config2.inc b/setup/class_setupStep_Config2.inc
index 2e502af5bfb31be8ec2f37d3cff846e1a18d96e7..e89f53db1667bed77558040761032cc138f8b6ab 100644
--- a/setup/class_setupStep_Config2.inc
+++ b/setup/class_setupStep_Config2.inc
@@ -39,7 +39,7 @@ class Step_Config2 extends setup_step
   var $attributes = array("timezone");
   var $called = FALSE;
 
-  function Step_Config2()
+  function __construct()
   {
     $this->update_strings();
 
diff --git a/setup/class_setupStep_Config3.inc b/setup/class_setupStep_Config3.inc
index 415947f33cf6210b08e930003807e8456609ad60..d09bb0daeaca7a86ae1b36d98dbdb5a122b527e2 100644
--- a/setup/class_setupStep_Config3.inc
+++ b/setup/class_setupStep_Config3.inc
@@ -62,7 +62,7 @@ class Step_Config3 extends setup_step
 
   var $attributes = array("errorlvl");
 
-  function Step_Config3()
+  function __construct()
   {
     $this->update_strings();
   }
@@ -201,9 +201,6 @@ class Step_Config3 extends setup_step
     if ($cv['id_settings']['minid_active']) {
       $attrs['fdMinId'] = $cv['id_settings']['minid'];
     }
-    //~ $attrs['fdGosaSharedPrefix'] = "";
-    //~ $attrs['fdLdapTLS']   = ($cv['tls']?"TRUE":"FALSE");
-    //~ $attrs['fdHonourIvbbAttributes']  = ($cv['governmentmode']?"TRUE":"FALSE");
     $attrs['fdHandleExpiredAccounts'] = ($cv['account_expiration']?"TRUE":"FALSE");
     $attrs['fdEnableSnapshots']       = ($cv['generic_settings']['snapshot_active']?"TRUE":"FALSE");
     $attrs['fdSnapshotBase']          = $cv['generic_settings']['snapshot_base'];
diff --git a/setup/class_setupStep_Finish.inc b/setup/class_setupStep_Finish.inc
index a56f3243eb4eec84234a03c43df699e139b47970..c1e391e96a8957fe275ea5f3bf93a67beec22bf0 100644
--- a/setup/class_setupStep_Finish.inc
+++ b/setup/class_setupStep_Finish.inc
@@ -23,9 +23,9 @@
 class Step_Finish extends setup_step
 {
   var $cfg_file_written = FALSE;
-  var $header_image = "images/setup/server.png";
+  var $header_image     = "images/setup/server.png";
 
-  function Step_Finish()
+  function __construct()
   {
     $this->update_strings();
   }
@@ -42,20 +42,19 @@ class Step_Finish extends setup_step
   function get_conf_data()
   {
     $smarty = get_smarty();
-    $smarty->assign("cv",xmlentities($this->parent->captured_values));
-    $smarty->assign("config_checksum", md5(file_get_contents(CONFIG_TEMPLATE_DIR.CONFIG_FILE)));
-    $str =  $smarty->fetch(CONFIG_TEMPLATE_DIR.CONFIG_FILE);
-    return($str);
+    $smarty->assign("cv",               xmlentities($this->parent->captured_values));
+    $smarty->assign("config_checksum",  md5(file_get_contents(CONFIG_TEMPLATE_DIR.CONFIG_FILE)));
+    return $smarty->fetch(CONFIG_TEMPLATE_DIR.CONFIG_FILE);
   }
 
 
   function execute()
   {
     global $BASE_DIR;
-    if(!function_exists("posix_getgrgid")){
+    if (!function_exists("posix_getgrgid")) {
       $webgroup = "";
     } else {
-      $info= posix_getgrgid(posix_getgid());
+      $info     = posix_getgrgid(posix_getgid());
       $webgroup = $info['name'];
     }
 
@@ -67,14 +66,14 @@ class Step_Finish extends setup_step
      *   - fusiondirectory.conf exists
      *   - Permisssion are set correctly
      */
-    if(isset($_POST['next']) && $exists && !$this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)){
+    if (isset($_POST['next']) && $exists && !$this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)) {
       session::destroy();
       header("Location: index.php");
       exit();
     }
 
     /* Download config */
-    if(isset($_POST['getconf'])){
+    if (isset($_POST['getconf'])) {
 
       header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
       header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
@@ -84,33 +83,32 @@ class Step_Finish extends setup_step
       header("Content-type: text/plain");
 
       if (preg_match('/MSIE 5.5/', $_SERVER['HTTP_USER_AGENT']) ||
-          preg_match('/MSIE 6.0/', $_SERVER['HTTP_USER_AGENT'])){
+          preg_match('/MSIE 6.0/', $_SERVER['HTTP_USER_AGENT'])) {
         header('Content-Disposition: filename="'.CONFIG_FILE.'"');
       } else {
         header('Content-Disposition: attachment; filename="'.CONFIG_FILE.'"');
       }
 
       $str = $this->get_conf_data();
-      $str = preg_replace("/\n[ ]*\n/","",$str);
+      $str = preg_replace("/\n[ ]*\n/", "", $str);
 
       echo $this->get_conf_data();
       exit();
     }
 
-    $err_msg= "";
+    $err_msg = "";
 
-    if($exists && $this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)){
+    if ($exists && $this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)) {
       $err_msg = _("Your configuration file is currently world readable. Please update the file permissions!");
-    }elseif(!$exists){
+    } elseif(!$exists) {
       $err_msg = _("The configuration is currently not readable or it does not exists.");
     }
 
     $smarty = get_smarty();
-    $smarty->assign("err_msg",$err_msg);
+    $smarty->assign("err_msg",  $err_msg);
+    $smarty->assign("msg2",     sprintf(_("After downloading and placing the file under %s, please make sure that the user the webserver is running with is able to read %s, while other users shouldn't."),CONFIG_DIR,CONFIG_FILE));
+    $smarty->assign("cv",       $this->parent->captured_values);
 
-    $smarty->assign("msg2", sprintf(_("After downloading and placing the file under %s, please make sure that the user the webserver is running with is able to read %s, while other users shouldn't."),CONFIG_DIR,CONFIG_FILE));
-
-    $smarty->assign("cv",$this->parent->captured_values);
     return $smarty->fetch("$BASE_DIR/setup/setup_finish.tpl");
   }
 
@@ -120,18 +118,16 @@ class Step_Finish extends setup_step
   {
     clearstatcache();
     $p = fileperms($file);
-    $w_r = (decbin($p & 4) == TRUE);
-    return($w_r);
+    return (decbin($p & 4) == TRUE);
   }
 
 
   function save_object()
   {
-    if(isset($_POST['step8_posted'])){
-
+    if (isset($_POST['step8_posted'])) {
       /* Get attributes */
-      foreach($this->attributes as $attr){
-        if(isset($_POST[$attr])){
+      foreach ($this->attributes as $attr) {
+        if (isset($_POST[$attr])) {
           $this->$attr = validate($_POST[$attr]);
         }
       }
@@ -139,5 +135,4 @@ class Step_Finish extends setup_step
   }
 }
 
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
diff --git a/setup/class_setupStep_Language.inc b/setup/class_setupStep_Language.inc
index 1b0ccee75e086a31ae47db3cc15578c6b311dce0..4968043201063c24b66e97ddf3d32621962b0ce9 100644
--- a/setup/class_setupStep_Language.inc
+++ b/setup/class_setupStep_Language.inc
@@ -29,7 +29,7 @@ class Step_Language extends setup_step
   var $attributes     = array("lang","lang_selected");
   var $header_image   = "images/setup/locale.png";
 
-  function Step_Language()
+  function __construct()
   {
     $this->lang           = get_browser_language();
     $this->lang_selected  = "";
@@ -47,29 +47,28 @@ class Step_Language extends setup_step
   {
     $this->languages = get_languages(TRUE);
     asort($this->languages);
-    $this->languages = array_merge(array(""      => _("Automatic")),$this->languages);
+    $this->languages = array_merge(array("" => _("Automatic")), $this->languages);
     $smarty = get_smarty();
-    $smarty->assign("languages",    $this->languages);
-    $smarty->assign("lang",         $this->lang);
-    $smarty->assign("rtl",          language_is_rtl($this->lang));
-    $smarty->assign("lang_selected",$this->lang_selected);
-    return($smarty->fetch(get_template_path("setup_language.tpl",TRUE,dirname(__FILE__))));
+    $smarty->assign("languages",      $this->languages);
+    $smarty->assign("lang",           $this->lang);
+    $smarty->assign("rtl",            language_is_rtl($this->lang));
+    $smarty->assign("lang_selected",  $this->lang_selected);
+    return $smarty->fetch(get_template_path("setup_language.tpl", TRUE, dirname(__FILE__)));
   }
 
   function save_object()
   {
-    if((isset($_POST['lang_selected'])) && isset($this->languages[$_POST['lang_selected']])) {
-      $this->lang_selected = $_POST['lang_selected'];
-      $this->is_completed = TRUE;
+    if ((isset($_POST['lang_selected'])) && isset($this->languages[$_POST['lang_selected']])) {
+      $this->lang_selected  = $_POST['lang_selected'];
+      $this->is_completed   = TRUE;
 
-      if($this->lang_selected != ""){
-        session::set('lang',$this->lang_selected);
-      }else{
-        session::set('lang',$this->lang);
+      if ($this->lang_selected != "") {
+        session::set('lang', $this->lang_selected);
+      } else {
+        session::set('lang', $this->lang);
       }
     }
   }
 }
 
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
diff --git a/setup/class_setupStep_Ldap.inc b/setup/class_setupStep_Ldap.inc
index ed326f462c5b4280240fea97997f24d10452b4d3..03626e55b1c069f4ed714911722add26e9e1f026 100644
--- a/setup/class_setupStep_Ldap.inc
+++ b/setup/class_setupStep_Ldap.inc
@@ -44,7 +44,7 @@ class Step_Ldap extends setup_step
 
   var $header_image = "images/setup/ldap.png";
 
-  function Step_Ldap()
+  function __construct()
   {
     $this->update_strings();
   }
diff --git a/setup/class_setupStep_Migrate.inc b/setup/class_setupStep_Migrate.inc
index 166ca28a76e5586ecd6f08e8c7349f7b430474f6..f2872be298a1ba6097e94b059faf3da8e27ae6f3 100644
--- a/setup/class_setupStep_Migrate.inc
+++ b/setup/class_setupStep_Migrate.inc
@@ -111,7 +111,7 @@ class Step_Migrate extends setup_step
   var $rootOC_migrate_dialog = FALSE;
   var $rootOC_details = array();
 
-  function Step_Migrate()
+  function __construct()
   {
     $this->update_strings();
   }
diff --git a/setup/class_setupStep_Schema.inc b/setup/class_setupStep_Schema.inc
index 6d4ab1271275f206410d3f0534283029bf6176c6..98641c5f2f4b4bf119ade11607d79a9ecdbff37b 100644
--- a/setup/class_setupStep_Schema.inc
+++ b/setup/class_setupStep_Schema.inc
@@ -22,16 +22,16 @@
 
 class Step_Schema extends setup_step
 {
-  var $checked = array();
-  var $not_checked = array();
-  var $schema_readable  = FALSE;
-  var $attributes       = array("enable_schema_check","samba_version");
-  var $enable_schema_check = TRUE;
-  var $samba_version       = 3;
+  var $checked              = array();
+  var $not_checked          = array();
+  var $schema_readable      = FALSE;
+  var $attributes           = array("enable_schema_check","samba_version");
+  var $enable_schema_check  = TRUE;
+  var $samba_version        = 3;
 
   var $found_ocs = 0;
 
-  function Step_Schema()
+  function __construct()
   {
     $this->update_strings();
   }
@@ -49,16 +49,16 @@ class Step_Schema extends setup_step
   {
     global $BASE_DIR;
     $this->check_schema();
-    $failed_checks = 0 ;
-    foreach($this->checked as $val) {
-      if(!$val['STATUS']){
+    $failed_checks = 0;
+    foreach ($this->checked as $val) {
+      if (!$val['STATUS']) {
         $failed_checks ++;
       }
     }
 
-    if($failed_checks == 0){
+    if ($failed_checks == 0) {
       $this->is_completed = TRUE;
-    }else{
+    } else {
       $this->is_completed = TRUE;
     }
 
@@ -84,24 +84,24 @@ class Step_Schema extends setup_step
     $ldap->set_size_limit(0);
 
     $smarty = get_smarty();
-    $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
+    $smarty->assign("bool",                 array(FALSE => _("No"), TRUE => _("Yes")));
     $smarty->assign("database_initialised", ($res == TRUE));
-    $smarty->assign("found_ocs", $this->found_ocs);
-    $smarty->assign("schema_readable",$this->schema_readable);
-    $smarty->assign("enable_schema_check",$this->enable_schema_check);
-    $smarty->assign("checks",$this->checked);
-    $smarty->assign("not_checked",$this->not_checked);
-    $smarty->assign("failed_checks",$failed_checks);
+    $smarty->assign("found_ocs",            $this->found_ocs);
+    $smarty->assign("schema_readable",      $this->schema_readable);
+    $smarty->assign("enable_schema_check",  $this->enable_schema_check);
+    $smarty->assign("checks",               $this->checked);
+    $smarty->assign("not_checked",          $this->not_checked);
+    $smarty->assign("failed_checks",        $failed_checks);
+
     return $smarty->fetch("$BASE_DIR/setup/setup_schema.tpl");
   }
 
   function save_object()
   {
-    if(isset($_POST['step7_posted'])){
-
+    if (isset($_POST['step7_posted'])) {
       /* Get attributes */
-      foreach($this->attributes as $attr){
-        if(isset($_POST[$attr])){
+      foreach ($this->attributes as $attr) {
+        if (isset($_POST[$attr])) {
           $this->$attr = validate($_POST[$attr]);
         }
       }
@@ -113,16 +113,16 @@ class Step_Schema extends setup_step
     $cfg = $this->parent->captured_values;
 
     /* Get objectclasses */
-    $ldap = new LDAP($cfg['admin'], $cfg['password'], $cfg['connection'], FALSE, $cfg['tls']);
-    $objectclasses = $ldap->get_objectclasses(TRUE);
-    $this->found_ocs = count($objectclasses);
-    $rfc2307bis = $cfg['rfc2307bis'];
-    $this->checked = check_schema($cfg,$rfc2307bis);
+    $ldap             = new LDAP($cfg['admin'], $cfg['password'], $cfg['connection'], FALSE, $cfg['tls']);
+    $objectclasses    = $ldap->get_objectclasses(TRUE);
+    $this->found_ocs  = count($objectclasses);
+    $rfc2307bis       = $cfg['rfc2307bis'];
+    $this->checked    = check_schema($cfg, $rfc2307bis);
 
     /* Which samba version do we use? */
     if (isset($objectclasses['sambaSamAccount'])) {
       $this->samba_version = 3;
-    } elseif(isset($objectclasses['sambaAccount'])) {
+    } elseif (isset($objectclasses['sambaAccount'])) {
       $this->samba_version = 2;
     } else {
       $this->samba_version = 0;
diff --git a/setup/class_setupStep_Welcome.inc b/setup/class_setupStep_Welcome.inc
index bdf2cead050462a4c0b6c91cff090537edeb9419..54775c0ccb5ae959990abcb362f16891239c0b0d 100644
--- a/setup/class_setupStep_Welcome.inc
+++ b/setup/class_setupStep_Welcome.inc
@@ -26,7 +26,7 @@ class Step_Welcome  extends setup_step
   var $attributes     = array();
   var $header_image   = "images/setup/welcome.png";
 
-  function Step_Welcome()
+  function __construct()
   {
     $this->is_enabled     = TRUE;
     $this->is_active      = TRUE;
@@ -45,8 +45,8 @@ class Step_Welcome  extends setup_step
     $smarty = get_smarty();
     $smarty->assign('auth_id', session_id());
 
-    $smarty->assign("path",'/tmp/fusiondirectory.auth');
-    return($smarty->fetch(get_template_path("setup_welcome.tpl",TRUE,dirname(__FILE__))));
+    $smarty->assign("path", '/tmp/fusiondirectory.auth');
+    return $smarty->fetch(get_template_path("setup_welcome.tpl", TRUE, dirname(__FILE__)));
   }
 
   function save_object()
@@ -55,20 +55,19 @@ class Step_Welcome  extends setup_step
 
     /* Get auth ID from file */
     $path = '/tmp/fusiondirectory.auth';
-    if (file_exists($path) && is_readable($path)){
-      $contents= file($path);
-      $id= chop($contents[0]);
+    if (file_exists($path) && is_readable($path)) {
+      $contents = file($path);
+      $id       = chop($contents[0]);
     }
 
     /* Continue if we've the correct ID */
-    if ($id == session_id()){
-      $this->is_completed = true;
+    if ($id == session_id()) {
+      $this->is_completed = TRUE;
     } else {
-      $this->is_completed = false;
+      $this->is_completed = FALSE;
     }
 
   }
 }
 
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>