Code

Only allow edit remove on certificates if user has write access
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 19 Jul 2006 07:07:22 +0000 (07:07 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 19 Jul 2006 07:07:22 +0000 (07:07 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4222 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/personal/generic/class_user.inc

index be511d51ce32eef21673f09f132b8687b9fca8c9..f784438a2af6e8c94185243fcc2a0c3455a41072 100644 (file)
@@ -390,57 +390,59 @@ class user extends plugin
 
 
     /* Remove certificate? */
-    foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12") as $val){
-      if (isset($_POST["remove_$val"])){
+    if($this->acl_is_writeable("Certificate")){ 
+      foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12") as $val){
+        if (isset($_POST["remove_$val"])){
 
-        /* Reset specified cert*/
-        $this->$val= "";
-        $this->is_modified= TRUE;
+          /* Reset specified cert*/
+          $this->$val= "";
+          $this->is_modified= TRUE;
+        }
       }
     }
 
-
     /* Upload new cert and close dialog? */    
-    if (isset($_POST['cert_edit_finish'])){
-
-      /* for all certificates do */
-      foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12")
-          as $val){
-
-        /* Check for clean upload */
-        if (array_key_exists($val."_file", $_FILES) &&
-            array_key_exists('name', $_FILES[$val."_file"]) &&
-            $_FILES[$val."_file"]['name'] != "" &&
-            is_uploaded_file($_FILES[$val."_file"]['tmp_name'])) {
-          $this->set_cert("$val", $_FILES[$val."_file"]['tmp_name']);
+    if($this->acl_is_writeable("Certificate")){ 
+      if (isset($_POST['cert_edit_finish'])){
+
+        /* for all certificates do */
+        foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12")
+            as $val){
+
+          /* Check for clean upload */
+          if (array_key_exists($val."_file", $_FILES) &&
+              array_key_exists('name', $_FILES[$val."_file"]) &&
+              $_FILES[$val."_file"]['name'] != "" &&
+              is_uploaded_file($_FILES[$val."_file"]['tmp_name'])) {
+            $this->set_cert("$val", $_FILES[$val."_file"]['tmp_name']);
+          }
         }
-      }
 
-      /* Save serial number */
-      if (isset($_POST["certificateSerialNumber"]) &&
-          $_POST["certificateSerialNumber"] != ""){
+        /* Save serial number */
+        if (isset($_POST["certificateSerialNumber"]) &&
+            $_POST["certificateSerialNumber"] != ""){
 
-        if (!is_id($_POST["certificateSerialNumber"])){
-          print_red (_("Please enter a valid serial number"));
+          if (!is_id($_POST["certificateSerialNumber"])){
+            print_red (_("Please enter a valid serial number"));
 
-          foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){
-            if ($this->$cert != ""){
-              $smarty->assign("$cert"."_state", "true");
-            } else {
-              $smarty->assign("$cert"."_state", "");
+            foreach(array("userCertificate", "userSMIMECertificate", "userPKCS12") as $cert){
+              if ($this->$cert != ""){
+                $smarty->assign("$cert"."_state", "true");
+              } else {
+                $smarty->assign("$cert"."_state", "");
+              }
             }
+            return ($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__))));
           }
-          return ($smarty->fetch (get_template_path('generic_certs.tpl', TRUE, dirname(__FILE__))));
+
+          $this->certificateSerialNumber= $_POST["certificateSerialNumber"];
+          $this->is_modified= TRUE;
         }
 
-        $this->certificateSerialNumber= $_POST["certificateSerialNumber"];
-        $this->is_modified= TRUE;
+        $this->cert_dialog= FALSE;
+        $this->dialog= FALSE;
       }
-
-      $this->cert_dialog= FALSE;
-      $this->dialog= FALSE;
     }
-
     /* Display picture dialog */
     if ($this->picture_dialog){
       return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
@@ -1145,6 +1147,7 @@ class user extends plugin
   /* Load certificate from file to object */
   function set_cert($cert, $filename)
   {
+    if(!$thsi->acl_is_writeable("Certificate")) return;
     $fd = fopen ($filename, "rb");
     if (filesize($filename)>0) {
       $this->$cert= fread ($fd, filesize ($filename));