steffen: server/kolab-webadmin/kolab-webadmin/php/admin/include form.class.php, 1.9, 1.10

cvs at intevation.de cvs at intevation.de
Thu Sep 23 13:02:45 CEST 2004


Author: steffen

Update of /kolabrepository/server/kolab-webadmin/kolab-webadmin/php/admin/include
In directory doto:/tmp/cvs-serv16033/kolab-webadmin/php/admin/include

Modified Files:
	form.class.php 
Log Message:
webgui for user/group specific policies

Index: form.class.php
===================================================================
RCS file: /kolabrepository/server/kolab-webadmin/kolab-webadmin/php/admin/include/form.class.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- form.class.php	31 Aug 2004 23:15:47 -0000	1.9
+++ form.class.php	23 Sep 2004 11:02:43 -0000	1.10
@@ -1,6 +1,6 @@
 <?php
 /*
- *  Copyright (c) 2004 Klarälvdalens Datakonsult AB
+ *  Copyright (c) 2004 KlarÃ��¤lvdalens Datakonsult AB
  *
  *    Writen by Steffen Hansen <steffen at klaralvdalens-datakonsult.se>
  *
@@ -55,7 +55,7 @@
     }*/
     $str .= '<form name="'.$this->name.'" method="post">';
     $str .= '<table class="contentformtable">';
-    $str .= _('<tr><th>Attribute</th><th>Value</th><th>Comment</th></tr>');
+    $str .= _('<tr><th>Attribute</th><th>Value</th><th>Comment</th></tr>')."\n";
     
     $size = 60;
     foreach( $this->entries as $key => $value ) {
@@ -79,7 +79,7 @@
 		  $str .= '<td><input name="'.$key.'" type="'.$value['type'].'" value="'.$value['value'].'" '.$value['attrs'].' size="'.$size.'" /></td>';
 		}
 		$str .= '<td>'.$value['comment'].'</td>';
-		$str .= '</tr>';
+		$str .= '</tr>'."\n";
 		break;
       case 'textarea':
 		$str .= '<tr>';
@@ -90,14 +90,14 @@
 		  $str .= '<td><textarea name="'.$key.'" rows="5" cols="'.$size.'" '.$value['attrs'].' onkeypress="javascript:textareakeypress()">'.$value['value'].'</textarea></td>';
 		}
 		$str .= '<td>'.$value['comment'].'</td>';
-		$str .= '</tr>';
+		$str .= '</tr>'."\n";
 		break;	
       case 'checkbox':
 		$str .= '<tr>';
 		$str .= '<td>'.$value['name'].'</td>';
 		$str .= '<td><input name="'.$key.'" type="'.$value['type'].'" value="on" '.($value['value']?'checked':'').' '.$value['attrs'].' /></td>';
         $str .= '<td>'.$value['comment'].'</td>';
-		$str .= '</tr>';
+		$str .= '</tr>'."\n";
 		break;	
 	  case 'select':
 		$str .= '<tr>';
@@ -106,49 +106,89 @@
 		  $str .= '<td><p>'.htmlentities($value['options'][$value['value']]).
 			'<input type="hidden" name="'.$key.'" value="'.$value['value'].'" /></p></td>';
 		} else {
-		  $str .= '<td><select name="'.$key.'" '.$value['attrs'].' >';
+		  $str .= '<td><select name="'.$key.'" '.$value['attrs'].' >'."\n";
 
 		  for( $i = 0; $i < count($value['options']); ++$i) {
 			if( $i == $value['value'] ) $s = 'selected';
 			else $s = '';
-			$str .= '<option value="'.$i.'" '.$s.'>'.htmlentities($value['options'][$i]).'</option>';
+			$str .= '<option value="'.$i.'" '.$s.'>'.htmlentities($value['options'][$i]).'</option>'."\n";
 		  }
 		  $str .= '</select>';
 		  $str .= '</td>';
 		}
         $str .= '<td>'.$value['comment'].'</td>';
-		$str .= '</tr>';
+		$str .= '</tr>'."\n";
 		break;
-      case 'aclselect':
+      case 'aclselect': // Special Kolab entry for ACLs
 		$str .= '<tr>';
 		$str .= '<td>'.$value['name'].'</td>';
 		$str .= '<td><input name="user_'.$key.'" type="'.$value['type'].'" size="'.($size-15).'" value="'.$value['user'].'" '.$value['attrs'].' />';
-		$str .= '<select name="perm_'.$key.'">';
+		$str .= '<select name="perm_'.$key.'">'."\n";
 		if( $value['perm'] ) $selected_perm = $value['perm'];
 		else $selected_perm = 'all';
 		foreach( array( 'none', 'read', 'post', 'append', 'write', 'read anon', 'read hidden', 'all' ) as $perm ) {
 		  if( $perm == $selected_perm ) $s = 'selected';
 		  else $s = '';
-		  $str .= '<option value="'.$perm.'"'.$s.' >'.$perm.'</option>';
+		  $str .= '<option value="'.$perm.'"'.$s.' >'.$perm.'</option>'."\n";
 		}
 		$str .= '</select>';
 		$str .= '</td>';
         $str .= '<td>'.$value['comment'].'</td>';
-		$str .= '</tr>';	
+		$str .= '</tr>'."\n";	
+		break;
+	  case 'resourcepolicy': // Special Kolab entry for group/resource policies
+		debug("resourcepolicy");
+		$str .= '<tr>';
+		$str .= '<td>'.$value['name'].'</td>';
+		$str .= '<td>';
+		$str .= '<table>';
+		$i = 0;
+		$tmppol = $value['policies'];
+		unset($tmppol['']);
+		ksort($tmppol);
+		$tmppol[''] = 0;
+		foreach( $tmppol as $user => $pol ) {
+		  debug("form: ".$user." => ".$pol);		  
+		  $str .= '<tr><td>';
+		  if( $user == 'anyone' ) {
+			$str .= 'Anyone<input type="hidden" name="user_'.$key.'_'.$i.'" value="'.$user.'" '.$value['attrs'].' />';
+		  } else {
+			$str .= '<input name="user_'.$key.'_'.$i.'" type="text" size="'.($size-20)
+			  .'" value="'.$user.'" '.$value['attrs'].' />';
+		  }
+		  $str .= '</td><td><select name="policy_'.$key.'_'.$i.'">'."\n";
+		  $j = 0;
+		  foreach( array( _('Always accept'), 
+						  _('Always reject'), 
+						  _('Reject if conflicts'), 
+						  _('Manual if conflicts'),
+						  _('Manual') ) as $p ) {
+			if( $j == $pol ) {
+			  $str .= '<option value="'.$j++.'" selected>'.$p.'</option>'."\n";			
+			} else {
+			  $str .= '<option value="'.$j++.'">'.$p.'</option>'."\n";
+			}
+		  }
+		  $i++;
+		  $str .= '</select></td></tr>'."\n";
+		}
+		$str .= '</table></td>';
+        $str .= '<td>'.$value['comment'].'</td>';
+		$str .= '</tr>'."\n";
 		break;
       }
     }
     $str .= '<tr><td colspan="3" align="center"><input type="submit" name="submit_'.$this->name.'" value="'
       .$this->submittext.'" '.$value['attrs'].' /></td></tr>';
-    $str .= '</table>';
+    $str .= '</table>'."\n";
     foreach( $this->entries as $key => $value ) {
       if( !isset( $value['type'] ) ) $value['type'] = '';
       if( !isset( $value['comment'] ) ) $value['comment'] = '';
       if( !isset( $value['attrs'] ) ) $value['attrs'] = '';
       if( $value['type'] == 'hidden' ) {
-		$str .= '<input name="'.$key.'" type="hidden" value="'.$value['value'].'" '.$value['attrs'].' />'; 
-      }      
-    }    
+		$str .= '<input name="'.$key.'" type="hidden" value="'.$value['value'].'" '.$value['attrs'].' />';
+      }
+    }
     $str .= '</form>';
     $str .= '</div>';
     return $str;
@@ -200,7 +240,16 @@
     foreach( $this->entries as $k => $v ) {
       if( $this->entries[$k]['type'] == 'aclselect' ) {
 		$this->entries[$k]['user'] = trim($this->value('user_'.$k));
-		$this->entries[$k]['perm'] = $this->value('perm_'.$k);	
+		$this->entries[$k]['perm'] = $this->value('perm_'.$k);
+	  } else if( $this->entries[$k]['type'] == 'resourcepolicy' ) {
+		$i = 0;
+		$pols = array();
+		while( isset($_REQUEST['user_'.$k.'_'.$i]) ) {
+		  $pols[trim($_REQUEST['user_'.$k.'_'.$i])]
+			= trim($_REQUEST['policy_'.$k.'_'.$i]);
+		  $i++;
+		}
+		$this->entries[$k]['policies'] = $pols;
       } else if( $this->entries[$k]['type'] == 'checkbox' ) {
 		$this->entries[$k]['value'] = isset( $_REQUEST[$k] );
       } else if( $this->entries[$k]['type'] == 'password' ) {





More information about the commits mailing list