Code

Fixed fax acls
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 2 Nov 2006 11:07:11 +0000 (11:07 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 2 Nov 2006 11:07:11 +0000 (11:07 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4996 594d385d-05f5-0310-b6e9-bd551577e9d8

include/functions.inc
plugins/gofax/faxaccount/class_gofaxAccount.inc
plugins/gofax/faxaccount/main.inc

index 286e0a18bb275dd5acbdd2c38405338ada99a816..376d19d86012519723c7714527d49328233c925d 100644 (file)
@@ -1182,12 +1182,7 @@ function get_printer_list($cups_server)
   /* Merge in printers from LDAP */
   $ldap= $config->get_ldap_link();
   $ldap->cd ($config->current['BASE']);
-  $ui= get_userinfo();
-  if (preg_match('/TRUE/i', $config->current['STRICT_UNITS']) && $ui->gosaUnitTag != ""){   
-    $ldap->search('((objectClass=gotoPrinter)(gosaUnitTag='.$ui->gosaUnitTag.'))', array('cn'));
-  } else {
-    $ldap->search('(objectClass=gotoPrinter)', array('cn'));
-  }
+  $ldap->search('(objectClass=gotoPrinter)', array('cn'));
 
   return $res;
 }
index f96b9ab20579dd7751a2c06d45fae7b3e70b7465..69dc4acab29417b2f56d03483df8ea52b800acab 100644 (file)
@@ -113,6 +113,9 @@ class gofaxAccount extends plugin
       }
     }
 
+    /* Edit mode specifies if we are editing from my accout */
+    $edit_mode = (!is_object($this->parent) && !isset($_SESSION['edit']));
+
     /* Load smarty stuff */
     $smarty= get_smarty();
 
@@ -157,7 +160,7 @@ class gofaxAccount extends plugin
 
     /* Trigger Add local fax alternatives dialog */
     if (isset($_POST['add_local_alternate'])){
-      if($this->acl_is_writeable("facsimileAlternateTelephoneNumber")){
+      if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){
         $this->locals_dialog= TRUE;    
         $this->dialog= TRUE;   
       }
@@ -165,7 +168,7 @@ class gofaxAccount extends plugin
 
     /* Add alternatives from dialog */
     if (isset($_POST['add_locals_finish']) && isset($_POST['local_list'])){
-      if($this->acl_is_writeable("facsimileAlternateTelephoneNumber")){
+      if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){
         foreach ($_POST['local_list'] as $val){
           $this->addAlternate($val);
           $this->is_modified= TRUE;
@@ -175,14 +178,14 @@ class gofaxAccount extends plugin
 
     /* Add alternatives */
     if (isset($_POST['add_alternate']) && !empty($_POST['forward_address']) && is_phone_nr($_POST['forward_address'])){ 
-      if($this->acl_is_writeable("facsimileAlternateTelephoneNumber")){
+      if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){
         $this->addAlternate($_POST['forward_address']);
       }
     }
 
     /* Delete alternate fax number */
     if (isset($_POST['delete_alternate']) && isset($_POST['alternate_list']) && count($_POST['alternate_list'])){ 
-      if($this->acl_is_writeable("facsimileAlternateTelephoneNumber")){
+      if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){
         $this->delAlternate ($_POST['alternate_list']);
       }
     }
@@ -190,7 +193,7 @@ class gofaxAccount extends plugin
 
     /* Edit incoming blocklists */
     if (isset($_POST['edit_incoming'])){
-      if($this->acl_is_writeable("goFaxRBlocklist"))  {
+      if($this->acl_is_writeable("goFaxRBlocklist",$edit_mode))  {
         $this->current_blocklist= array_merge($this->goFaxRBlocklist,$this->goFaxRBlockgroups);
         sort($this->current_blocklist);
         reset($this->current_blocklist);
@@ -563,7 +566,7 @@ class gofaxAccount extends plugin
 
     $tmp = $this->plInfo();
     foreach($tmp['plProvidedAcls'] as $acl => $desc){
-      $smarty->assign($acl."ACL",$this->getacl($acl));
+      $smarty->assign($acl."ACL",$this->getacl($acl,$edit_mode));
     }
 
     /* Load checkboxes */
@@ -659,20 +662,21 @@ class gofaxAccount extends plugin
   /* Save data to object */
   function save_object()
   {
+    $edit_mode = (!is_object($this->parent) && !isset($_SESSION['edit']));
     if (isset($_POST['faxTab'])){
       plugin::save_object();
 
 
       $tmp = 0+$this->goFaxDeliveryMode;
 
-      if($this->acl_is_writeable("faxtomail")){
+      if($this->acl_is_writeable("faxtomail",$edit_mode)){
         if (isset($_POST["faxtomail"]) && $_POST["faxtomail"] == 1){  
           $tmp |= 32;
         }elseif($tmp & 32){
           $tmp &= (!32);
         }
       }
-      if($this->acl_is_writeable("faxtoprinter")){
+      if($this->acl_is_writeable("faxtoprinter",$edit_mode)){
         if (isset($_POST["faxtoprinter"]) && $_POST["faxtoprinter"] == 1){  
           $tmp |= 64;
         }elseif($tmp & 64){
@@ -681,7 +685,7 @@ class gofaxAccount extends plugin
       }
       $this->goFaxDeliveryMode = $tmp;
 
-      if($this->acl_is_writeable("goFaxIsEnabled")){
+      if($this->acl_is_writeable("goFaxIsEnabled",$edit_mode)){
         if (isset($_POST["goFaxIsEnabled"]) && $_POST["goFaxIsEnabled"] == "1"){
           $this->goFaxIsEnabled= "0";
         } else {
@@ -690,14 +694,16 @@ class gofaxAccount extends plugin
       }
 
     
-      if (isset($_POST['mail']) && $this->acl_is_writeable("faxtomail")){
+      if (isset($_POST['mail']) && $this->acl_is_writeable("faxtomail",$edit_mode)){
         $this->mail= $_POST['mail'];
       }
 
       /* Check if mail account is active and correct the internal
          reference to represent the current status. */
-      if (isset($this->parent->by_object['mailAccount']->is_account)&&($this->parent->by_object['mailAccount']->is_account)){
-        $this->has_mailAccount= TRUE;
+      if(isset($this->parent)){
+        if (isset($this->parent->by_object['mailAccount']->is_account)&&($this->parent->by_object['mailAccount']->is_account)){
+          $this->has_mailAccount= TRUE;
+        }
       }
     }
 
index ab20ed675da4c2a999e7800d42a0ece0199eeaa1..0f1817415806d723efe0830de79a20f626126737 100644 (file)
@@ -1,4 +1,8 @@
 <?php
+
+$display  ="";
+$lock_msg = "";
+
 if (!$remove_lock){
 
        /* Reset requested? */
@@ -30,14 +34,16 @@ if (!$remove_lock){
                /* Check locking */
                if (($username= get_lock($ui->dn)) != ""){
                        $_SESSION['back_plugin']= $plug;
-                       gen_locked_message ($username, $ui->dn);
-                       exit ();
-               }
+                       $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/");
+                       $lock_msg =  gen_locked_message ($username, $ui->dn);
+
+               }else{
 
-               /* Lock the current entry */
-               add_lock ($ui->dn, $ui->dn);
-               $_SESSION['dn']= $ui->dn;
-               $_SESSION['edit']= TRUE;
+                       /* Lock the current entry */
+                       add_lock ($ui->dn, $ui->dn);
+                       $_SESSION['dn']= $ui->dn;
+                       $_SESSION['edit']= TRUE;
+               }
        }
 
        /* save changes to LDAP and disable edit mode */
@@ -60,7 +66,12 @@ if (!$remove_lock){
         }
 
        /* Execute formular */
-       $display= $gofaxAccount->execute ();
+       if($lock_msg){
+               $display.= $lock_msg;
+       }else{
+               $display.= $gofaxAccount->execute ();
+       }
+
        $info= "";
 
        /* Store changes  in session */
@@ -72,7 +83,8 @@ if (!$remove_lock){
        if (!$gofaxAccount->locals_dialog &&
                !$gofaxAccount->out_blocklist_dialog &&
                !$gofaxAccount->in_blocklist_dialog &&
-               $gofaxAccount->is_account){
+               $gofaxAccount->is_account       && 
+               empty($lock_msg)){
 
                $display.= "<p class=\"plugbottom\">\n";