gunnar: server/kolab-webadmin/kolab-webadmin/php/admin/include form.class.php, 1.29, 1.30

cvs at kolab.org cvs at kolab.org
Thu May 24 11:50:01 CEST 2007


Author: gunnar

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

Modified Files:
	form.class.php 
Log Message:
Fixed kolab/issue1620 (https://intevation.de/roundup/kolab/issue1620)


Index: form.class.php
===================================================================
RCS file: /kolabrepository/server/kolab-webadmin/kolab-webadmin/php/admin/include/form.class.php,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- form.class.php	10 Jan 2007 12:25:43 -0000	1.29
+++ form.class.php	24 May 2007 09:49:58 -0000	1.30
@@ -51,22 +51,23 @@
    */
   function __toString() {
     return sprintf("Debuginformation for class: %s; name: %s; template: %s;", get_class($this), $this->name, $this->template);
-   }
+  }
 
-  /*private*/function comment_helper( &$value ) {
-	  $ast = '';
-	  if( isset($value['validation'])){
-		  if( is_array( $value['validation'] ) && in_array( 'notempty', $value['validation']) ) {
-			  $ast = '<span class="required_asterisk">*</span> ';
-		  } else if( $value['validation'] == 'notempty' ) {
-			  $ast = '<span class="required_asterisk">*</span> ';			  
-		  }
-	  }
-	  return $ast.$value['comment'];
+  /*private*/
+  function comment_helper( &$value ) {
+    $ast = '';
+    if( isset($value['validation'])){
+      if( is_array( $value['validation'] ) && in_array( 'notempty', $value['validation']) ) {
+	$ast = '<span class="required_asterisk">*</span> ';
+      } else if( $value['validation'] == 'notempty' ) {
+	$ast = '<span class="required_asterisk">*</span> ';			  
+      }
+    }
+    return $ast.$value['comment'];
   }
   
   function outputForm() {
-	  debug_var_dump($this->entries);
+    debug_var_dump($this->entries);
     $str = '<div class="contentform">';
     /*
     if( count( $this->errors ) > 0 ) {
@@ -89,231 +90,231 @@
       switch( $value['type'] ) {
       case 'hidden': continue;
       case 'password':
-		if( ereg( 'readonly', $value['attrs'] ) ) {		  
-		  // If readonly, skip it -- passwords are at most write-only
-		  break;
-		}
+	if( ereg( 'readonly', $value['attrs'] ) ) {		  
+	  // If readonly, skip it -- passwords are at most write-only
+	  break;
+	}
       case 'input':
       case 'text':
-		$str .= '<tr>';
-		$str .= '<td>'.$value['name'].'</td>';
-		if( ereg( 'readonly', $value['attrs'] ) ) {
-		  $str .= '<td><p class="ctrl">'.MySmarty::htmlentities($value['value']).'</p><input name="'
-			.$key.'" type="hidden" value="'.MySmarty::htmlentities($value['value']).'" /></td>';
-		} else {
-		  $str .= '<td><input name="'.$key.'" type="'.$value['type'].'" value="'.MySmarty::htmlentities($value['value']).'" '
-			.MySmarty::htmlentities($value['attrs']).' size="'.$size.'" /></td>';
-		}
-		$str .= '<td>'.KolabForm::comment_helper($value).'</td>';
-		$str .= '</tr>'."\n";
-		break;
-	  case 'email':
-		$str .= '<tr>';
-		$str .= '<td>'.$value['name'].'</td>';
-		if( strpos($value['value'],'@')===false ) {
-		  $uname = $value['value'];
-		  $domain = '';
-		} else {
-		  list($uname,$domain) = split('@',$value['value']);
-		}
-		if( ereg( 'readonly', $value['attrs'] ) ) {
-		  $str .= '<td><p class="ctrl">'.MySmarty::htmlentities($value['value']).'</p><input name="user_'.$key.'" type="hidden" value="'.
-			MySmarty::htmlentities($uname).'" /><input name="domain_'.$key.'" type="hidden" value="'.
-			MySmarty::htmlentities($domain).'" /></td>';
-		} else {
-		  $str .= '<td><input name="user_'.$key.'" type="text" value="'.MySmarty::htmlentities($uname).'" '
-			.$value['attrs'].' size="'.($size-40).'" />';
-		  if( count($value['domains']) == 1 ) {
-			$str .= '<input name="domain_'.$key.'" type="hidden" value="'.MySmarty::htmlentities($value['domains'][0]).'" />';
-			$str .= '<span class="ctrl">@'.MySmarty::htmlentities($value['domains'][0]).'</span></td>';
-		  } else {
-			$str .= '@<select name="domain_'.$key.'" '.$value['attrs']." >\n";
-			foreach( $value['domains'] as $dom ) {
-			  if( $dom == $domain ) $s = 'selected';
-			  else $s = '';
-			  $str .= '<option value="'.MySmarty::htmlentities($dom).'" '.$s.'>'.MySmarty::htmlentities($dom).'</option>'."\n";
-			}
-			$str .= '</select>';
-			$str .= '</td>';
-		  }
-		}
-		$str .= '<td>'.KolabForm::comment_helper($value).'</td>';
-		$str .= '</tr>'."\n";
-		break;
-	  case 'comment':
-		$str .= '<tr>';
-		$str .= '<td>'.$value['name'].'</td>';
-		$str .= '<td>'.$value['value'].'</td>';
-		$str .= '<td>'.KolabForm::comment_helper($value).'</td>';
-		$str .= '</tr>'."\n";
-		break;
+	$str .= '<tr>';
+	$str .= '<td>'.$value['name'].'</td>';
+	if( ereg( 'readonly', $value['attrs'] ) ) {
+	  $str .= '<td><p class="ctrl">'.MySmarty::htmlentities($value['value']).'</p><input name="'
+	    .$key.'" type="hidden" value="'.MySmarty::htmlentities($value['value']).'" /></td>';
+	} else {
+	  $str .= '<td><input name="'.$key.'" type="'.$value['type'].'" value="'.MySmarty::htmlentities($value['value']).'" '
+	    .MySmarty::htmlentities($value['attrs']).' size="'.$size.'" /></td>';
+	}
+	$str .= '<td>'.KolabForm::comment_helper($value).'</td>';
+	$str .= '</tr>'."\n";
+	break;
+      case 'email':
+	$str .= '<tr>';
+	$str .= '<td>'.$value['name'].'</td>';
+	if( strpos($value['value'],'@')===false ) {
+	  $uname = $value['value'];
+	  $domain = '';
+	} else {
+	  list($uname,$domain) = split('@',$value['value']);
+	}
+	if( ereg( 'readonly', $value['attrs'] ) ) {
+	  $str .= '<td><p class="ctrl">'.MySmarty::htmlentities($value['value']).'</p><input name="user_'.$key.'" type="hidden" value="'.
+	    MySmarty::htmlentities($uname).'" /><input name="domain_'.$key.'" type="hidden" value="'.
+	    MySmarty::htmlentities($domain).'" /></td>';
+	} else {
+	  $str .= '<td><input name="user_'.$key.'" type="text" value="'.MySmarty::htmlentities($uname).'" '
+	    .$value['attrs'].' size="'.($size-40).'" />';
+	  if( count($value['domains']) == 1 ) {
+	    $str .= '<input name="domain_'.$key.'" type="hidden" value="'.MySmarty::htmlentities($value['domains'][0]).'" />';
+	    $str .= '<span class="ctrl">@'.MySmarty::htmlentities($value['domains'][0]).'</span></td>';
+	  } else {
+	    $str .= '@<select name="domain_'.$key.'" '.$value['attrs']." >\n";
+	    foreach( $value['domains'] as $dom ) {
+	      if( $dom == $domain ) $s = 'selected="selected"';
+	      else $s = '';
+	      $str .= '<option value="'.MySmarty::htmlentities($dom).'" '.$s.'>'.MySmarty::htmlentities($dom).'</option>'."\n";
+	    }
+	    $str .= '</select>';
+	    $str .= '</td>';
+	  }
+	}
+	$str .= '<td>'.KolabForm::comment_helper($value).'</td>';
+	$str .= '</tr>'."\n";
+	break;
+      case 'comment':
+	$str .= '<tr>';
+	$str .= '<td>'.$value['name'].'</td>';
+	$str .= '<td>'.$value['value'].'</td>';
+	$str .= '<td>'.KolabForm::comment_helper($value).'</td>';
+	$str .= '</tr>'."\n";
+	break;
       case 'textarea':
-		$str .= '<tr>';
-		$str .= '<td>'.$value['name'].'</td>';
-		if( ereg( 'readonly', $value['attrs'] ) ) {
-		  $str .= '<td><p class="ctrl">'.MySmarty::htmlentities($value['value']).'</p></td>';
-		} else {
-		  $str .= '<td><textarea name="'.$key.'" rows="5" cols="'.$size.'" '.$value['attrs'].' onkeypress="javascript:textareakeypress()">'.MySmarty::htmlentities($value['value']).'</textarea></td>';
-		}
-		$str .= '<td>'.KolabForm::comment_helper($value).'</td>';
-		$str .= '</tr>'."\n";
-		break;	
+	$str .= '<tr>';
+	$str .= '<td>'.$value['name'].'</td>';
+	if( ereg( 'readonly', $value['attrs'] ) ) {
+	  $str .= '<td><p class="ctrl">'.MySmarty::htmlentities($value['value']).'</p></td>';
+	} else {
+	  $str .= '<td><textarea name="'.$key.'" rows="5" cols="'.$size.'" '.$value['attrs'].' onkeypress="javascript:textareakeypress()">'.MySmarty::htmlentities($value['value']).'</textarea></td>';
+	}
+	$str .= '<td>'.KolabForm::comment_helper($value).'</td>';
+	$str .= '</tr>'."\n";
+	break;	
       case 'checkbox':
-		$str .= '<tr>';
-		$str .= '<td>'.$value['name'].'</td>';
-		if( ereg( 'readonly', $value['attrs'] ) ) {
-		  $str .= '<td><span class="ctrl">'.($value['value']?_('Yes'):_('No')).'</span></td>';
-		} else {
-		  $str .= '<td><input name="'.$key.'" type="'.$value['type'].'" value="on" '.($value['value']?'checked':'').' '.$value['attrs'].' /></td>';
-		}
-        $str .= '<td>'.KolabForm::comment_helper($value).'</td>';
-		$str .= '</tr>'."\n";
-		break;	
-	  case 'checklist':
-		$str .= '<tr>';
-		$str .= '<td>'.$value['name'].'</td>';
-		if( ereg( 'readonly', $value['attrs'] ) ) {
-		  $str .= '<td><span class="ctrl">'.(join('<br/>',$value['options'])).'</span></td>';
-		} else {
-		  $str .= '<td><table class="contentform">';
-		  foreach( $value['options'] as $opt ) {
-			if( is_array( $value['value'] ) ) $checked = ( in_array($opt ,$value['value'] ))?"checked":"";
-			else $checked = "";
-			//debug("Checking if $opt is in ".join(",",$value['value'])." :$checked");
-			$str .= '<tr><td><input name="'.$key.'[]" type="checkbox" value="'.MySmarty::htmlentities($opt).'" '.$value['attrs']." $checked /></td><td>"
-			  .MySmarty::htmlentities($opt).'</td></tr>';
-		  }
-		  $str .= '</table></td>';
-		}
-        $str .= '<td>'.$value['comment'].'</td>';
-		$str .= '</tr>'."\n";
-		break;			
-	  case 'select':
-		$str .= '<tr>';
-		$str .= '<td>'.$value['name'].'</td>';
-		if( ereg( 'readonly', $value['attrs'] ) ) {
-		  $str .= '<td><p class="ctrl">'.MySmarty::htmlentities($value['options'][$value['value']]).
-			'<input type="hidden" name="'.$key.'" value="'.MySmarty::htmlentities($value['value']).'" /></p></td>';
-		} else {
-		  $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.'>'.MySmarty::htmlentities($value['options'][$i]).'</option>'."\n";
-		  }
-		  $str .= '</select>';
-		  $str .= '</td>';
-		}
-        $str .= '<td>'.KolabForm::comment_helper($value).'</td>';
-		$str .= '</tr>'."\n";
-		break;
-	  case 'foldertypeselect':
-		$str .= '<tr>';
-		$str .= '<td>'.$value['name'].'</td>';
-                $entries = array ( '' => _('Unspecified'), 'mail' => _('Mails'), 'task' => _('Tasks'), 
-								   'journal' => _('Journals'), 'event' => _('Events'), 
-								   'contact' => _('Contacts'), 'note' => _('Notes'));
-		if( ereg( 'readonly', $value['attrs'] ) ) {
-		  $str .= '<td><p class="ctrl">'.MySmarty::htmlentities($entries[$value['value']]).
-			'<input type="hidden" name="'.$key.'" value="'.MySmarty::htmlentities($value['value']).'" /></p></td>';
-		} else {
-		  $str .= '<td><select name="'.$key.'" '.$value['attrs'].' >'."\n";
-		  foreach ($entries as $id => $title) {
-		  	if ( $value['value'] == $id )
-				$s = 'selected';
-			else
-				$s = '';
-
-		  	$str .= '<option value="'.$id.'" '.$s.'>'.MySmarty::htmlentities($title).'</option>'."\n";
-		  }
-		  $str .= '</select>';
-		  $str .= '</td>';
-		}
-        	$str .= '<td>'.$value['comment'].'</td>';
-		$str .= '</tr>'."\n";
-		break;
+	$str .= '<tr>';
+	$str .= '<td>'.$value['name'].'</td>';
+	if( ereg( 'readonly', $value['attrs'] ) ) {
+	  $str .= '<td><span class="ctrl">'.($value['value']?_('Yes'):_('No')).'</span></td>';
+	} else {
+	  $str .= '<td><input name="'.$key.'" type="'.$value['type'].'" value="on" '.($value['value']?'checked':'').' '.$value['attrs'].' /></td>';
+	}
+	$str .= '<td>'.KolabForm::comment_helper($value).'</td>';
+	$str .= '</tr>'."\n";
+	break;	
+      case 'checklist':
+	$str .= '<tr>';
+	$str .= '<td>'.$value['name'].'</td>';
+	if( ereg( 'readonly', $value['attrs'] ) ) {
+	  $str .= '<td><span class="ctrl">'.(join('<br/>',$value['options'])).'</span></td>';
+	} else {
+	  $str .= '<td><table class="contentform">';
+	  foreach( $value['options'] as $opt ) {
+	    if( is_array( $value['value'] ) ) $checked = ( in_array($opt ,$value['value'] ))?"checked":"";
+	    else $checked = "";
+	    //debug("Checking if $opt is in ".join(",",$value['value'])." :$checked");
+	    $str .= '<tr><td><input name="'.$key.'[]" type="checkbox" value="'.MySmarty::htmlentities($opt).'" '.$value['attrs']." $checked /></td><td>"
+	      .MySmarty::htmlentities($opt).'</td></tr>';
+	  }
+	  $str .= '</table></td>';
+	}
+	$str .= '<td>'.$value['comment'].'</td>';
+	$str .= '</tr>'."\n";
+	break;			
+      case 'select':
+	$str .= '<tr>';
+	$str .= '<td>'.$value['name'].'</td>';
+	if( ereg( 'readonly', $value['attrs'] ) ) {
+	  $str .= '<td><p class="ctrl">'.MySmarty::htmlentities($value['options'][$value['value']]).
+	    '<input type="hidden" name="'.$key.'" value="'.MySmarty::htmlentities($value['value']).'" /></p></td>';
+	} else {
+	  $str .= '<td><select name="'.$key.'" '.$value['attrs'].' >'."\n";
+	  
+	  for( $i = 0; $i < count($value['options']); ++$i) {
+	    if( $i == $value['value'] ) $s = 'selected="selected"';
+	    else $s = '';
+	    $str .= '<option value="'.$i.'" '.$s.'>'.MySmarty::htmlentities($value['options'][$i]).'</option>'."\n";
+	  }
+	  $str .= '</select>';
+	  $str .= '</td>';
+	}
+	$str .= '<td>'.KolabForm::comment_helper($value).'</td>';
+	$str .= '</tr>'."\n";
+	break;
+      case 'foldertypeselect':
+	$str .= '<tr>';
+	$str .= '<td>'.$value['name'].'</td>';
+	$entries = array ( '' => _('Unspecified'), 'mail' => _('Mails'), 'task' => _('Tasks'), 
+			   'journal' => _('Journals'), 'event' => _('Events'), 
+			   'contact' => _('Contacts'), 'note' => _('Notes'));
+	if( ereg( 'readonly', $value['attrs'] ) ) {
+	  $str .= '<td><p class="ctrl">'.MySmarty::htmlentities($entries[$value['value']]).
+	    '<input type="hidden" name="'.$key.'" value="'.MySmarty::htmlentities($value['value']).'" /></p></td>';
+	} else {
+	  $str .= '<td><select name="'.$key.'" '.$value['attrs'].' >'."\n";
+	  foreach ($entries as $id => $title) {
+	    if ( $value['value'] == $id )
+	      $s = 'selected="selected"';
+	    else
+	      $s = '';
+	    
+	    $str .= '<option value="'.$id.'" '.$s.'>'.MySmarty::htmlentities($title).'</option>'."\n";
+	  }
+	  $str .= '</select>';
+	  $str .= '</td>';
+	}
+	$str .= '<td>'.$value['comment'].'</td>';
+	$str .= '</tr>'."\n";
+	break;
       case 'aclselect': // Special Kolab entry for ACLs
-		$str .= '<tr>';
-		$str .= '<td>'.$value['name'].'</td>';
-		if( ereg( 'readonly', $value['attrs'] ) ) {
-		  if( $value['user'] ) $str .= '<td><span class="ctrl">'.MySmarty::htmlentities($value['user']).'</span> <span class="ctrl">'.$value['perm'].'</span></td>';
-		} else {
-		  $str .= '<td><input name="user_'.$key.'" type="'.$value['type'].'" size="'.($size-15).'" value="'
-			.MySmarty::htmlentities($value['user']).'" '.$value['attrs'].' />';
-		  $str .= '<select name="perm_'.$key.'">'."\n";
-		  if( $value['perm'] ) $selected_perm = $value['perm'];
-		  else $selected_perm = 'all';
-		  foreach( array( 'none', 
-						  'post', 
-						  'read', 'read/post', 
-						  'append', 
-						  'write', 
-						  'read anon', 
-						  'read anon/post', 
-						  'read hidden', 
-						  'read hidden/post', 
-						  'all' ) as $perm ) {
-			if( $perm == $selected_perm ) $s = 'selected';
-			else $s = '';
-			$str .= '<option value="'.$perm.'"'.$s.' >'.$perm.'</option>'."\n";
-		  }
-		  $str .= '</select>';
-		  $str .= '</td>';
-		}
-		$str .= '<td>'.KolabForm::comment_helper($value).'</td>';
-		$str .= '</tr>'."\n";	
-		break;
-	  case 'resourcepolicy': // Special Kolab entry for group/resource policies
-		debug("resourcepolicy");
-		$ro = ereg( 'readonly', $value['attrs'] );
-		$str .= '<tr>';
-		$str .= '<td>'.$value['name'].'</td>';
-		$str .= '<td>';
-		$str .= '<table>';
-		$i = 0;
-		$tmppol = $value['policies'];
-		unset($tmppol['']);
-		ksort($tmppol);
-		$tmppol[''] = 0;
-		$policies = array( _('Always accept'), 
-						   _('Always reject'), 
-						   _('Reject if conflicts'), 
-						   _('Manual if conflicts'),
-						   _('Manual') );
-		foreach( $tmppol as $user => $pol ) {
-		  debug("form: ".$user." => ".$pol);		  
-		  if( $ro ) {
-			if( !$user ) continue;
-			$str .= '<tr><td>';
-			if( $user == 'anyone' ) $str .= '<p class="ctrl">'._('Anyone').'</p>';
-			else $str .= '<p class="ctrl">'.MySmarty::htmlentities($user).'</p>';
-			$str .= '</td><td><p class="ctrl">'.MySmarty::htmlentities($policies[$pol]).'</p></td></tr>'."\n";
-		  } else {
-			$str .= '<tr><td>';
-			if( $user == 'anyone' ) {
-			  $str .= _('Anyone').'<input type="hidden" name="user_'.$key.'_'.$i.'" value="'.MySmarty::htmlentities($user).'" '.$value['attrs'].' />';
-			} else {
-			  $str .= '<input name="user_'.$key.'_'.$i.'" type="text" size="'.($size-20)
-				.'" value="'.MySmarty::htmlentities($user).'" '.$value['attrs'].' />';
-			}
-			$str .= '</td><td><select name="policy_'.$key.'_'.$i.'">'."\n";
-			$j = 0;
-			foreach( $policies 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>'.KolabForm::comment_helper($value).'</td>';
-		$str .= '</tr>'."\n";
-		break;
+	$str .= '<tr>';
+	$str .= '<td>'.$value['name'].'</td>';
+	if( ereg( 'readonly', $value['attrs'] ) ) {
+	  if( $value['user'] ) $str .= '<td><span class="ctrl">'.MySmarty::htmlentities($value['user']).'</span> <span class="ctrl">'.$value['perm'].'</span></td>';
+	} else {
+	  $str .= '<td><input name="user_'.$key.'" type="text" size="'.($size-15).'" value="'
+	    .MySmarty::htmlentities($value['user']).'" '.$value['attrs'].' />';
+	  $str .= '<select name="perm_'.$key.'">'."\n";
+	  if( $value['perm'] ) $selected_perm = $value['perm'];
+	  else $selected_perm = 'all';
+	  foreach( array( 'none', 
+			  'post', 
+			  'read', 'read/post', 
+			  'append', 
+			  'write', 
+			  'read anon', 
+			  'read anon/post', 
+			  'read hidden', 
+			  'read hidden/post', 
+			  'all' ) as $perm ) {
+	    if( $perm == $selected_perm ) $s = 'selected="selected"';
+	    else $s = '';
+	    $str .= '<option value="'.$perm.'"'.$s.' >'.$perm.'</option>'."\n";
+	  }
+	  $str .= '</select>';
+	  $str .= '</td>';
+	}
+	$str .= '<td>'.KolabForm::comment_helper($value).'</td>';
+	$str .= '</tr>'."\n";	
+	break;
+      case 'resourcepolicy': // Special Kolab entry for group/resource policies
+	debug("resourcepolicy");
+	$ro = ereg( 'readonly', $value['attrs'] );
+	$str .= '<tr>';
+	$str .= '<td>'.$value['name'].'</td>';
+	$str .= '<td>';
+	$str .= '<table>';
+	$i = 0;
+	$tmppol = $value['policies'];
+	unset($tmppol['']);
+	ksort($tmppol);
+	$tmppol[''] = 0;
+	$policies = array( _('Always accept'), 
+			   _('Always reject'), 
+			   _('Reject if conflicts'), 
+			   _('Manual if conflicts'),
+			   _('Manual') );
+	foreach( $tmppol as $user => $pol ) {
+	  debug("form: ".$user." => ".$pol);		  
+	  if( $ro ) {
+	    if( !$user ) continue;
+	    $str .= '<tr><td>';
+	    if( $user == 'anyone' ) $str .= '<p class="ctrl">'._('Anyone').'</p>';
+	    else $str .= '<p class="ctrl">'.MySmarty::htmlentities($user).'</p>';
+	    $str .= '</td><td><p class="ctrl">'.MySmarty::htmlentities($policies[$pol]).'</p></td></tr>'."\n";
+	  } else {
+	    $str .= '<tr><td>';
+	    if( $user == 'anyone' ) {
+	      $str .= _('Anyone').'<input type="hidden" name="user_'.$key.'_'.$i.'" value="'.MySmarty::htmlentities($user).'" '.$value['attrs'].' />';
+	    } else {
+	      $str .= '<input name="user_'.$key.'_'.$i.'" type="text" size="'.($size-20)
+		.'" value="'.MySmarty::htmlentities($user).'" '.$value['attrs'].' />';
+	    }
+	    $str .= '</td><td><select name="policy_'.$key.'_'.$i.'">'."\n";
+	    $j = 0;
+	    foreach( $policies as $p ) {
+	      if( $j == $pol ) {
+		$str .= '<option value="'.$j++.'" selected="selected">'.$p.'</option>'."\n";			
+	      } else {
+		$str .= '<option value="'.$j++.'">'.$p.'</option>'."\n";
+	      }
+	    }
+	    $i++;
+	    $str .= '</select></td></tr>'."\n";
+	  }
+	}
+	$str .= '</table></td>';
+	$str .= '<td>'.KolabForm::comment_helper($value).'</td>';
+	$str .= '</tr>'."\n";
+	break;
       }
     }
     $str .= '<tr><td colspan="3" align="center"><input type="submit" name="submit_'.$this->name.'" value="'
@@ -324,56 +325,56 @@
       if( !isset( $value['comment'] ) ) $value['comment'] = '';
       if( !isset( $value['attrs'] ) ) $value['attrs'] = '';
       if( $value['type'] == 'hidden' ) {
-		$str .= '<input name="'.$key.'" type="hidden" value="'.MySmarty::htmlentities($value['value']).'" '.$value['attrs'].' />';
+	$str .= '<input name="'.$key.'" type="hidden" value="'.MySmarty::htmlentities($value['value']).'" '.$value['attrs'].' />';
       }
     }
     $str .= '</form>';
-	$str .= '<div class="required_asterisk">'._('* Required field.').'</div>';
+    $str .= '<div class="required_asterisk">'._('* Required field.').'</div>';
     $str .= '</div>';
     return $str;
   }
-
+  
   function validate() {
     $this->errors = array();
     foreach( $this->entries as $key => $value ) {
       if( !empty( $value['validation'] ) && !ereg( 'readonly', $value['attrs'] ) ) {
-		$vv = $value['validation'];
-		if( !is_array($vv) ) $va = array($vv);
-		else $va = $vv;
-		foreach( $va as $v ) {
-		  //print "validating using $v <br/>";
-		  if( $v == 'notempty' ) {
-			debug("checking nonemptiness of $key: ".KolabForm::getRequestVar($key)." len=".strlen(trim(KolabForm::getRequestVar($key))));
-			if( $value['type'] == 'aclselect' ) {
-			  // ignore
-			} else if( $value['type'] == 'email' ) {
-			  debug('Checking '.$value['name'].': '.$_REQUEST['user_'.$key]);
-			  if( strlen(trim($_REQUEST['user_'.$key])) == 0 ) {
-				  $this->errors[] = _('Required field ').$value['name']._(' is empty');
-			  }
-			} else if( strlen( trim($_REQUEST[$key]) ) == 0 ) {
-			  $this->errors[] = _('Required field ').$value['name']._(' is empty');
-			}
-		  } else {
-			if( $value['type'] == 'aclselect' ) {
-			  $data = $_REQUEST['user_'.$key].' '.$_REQUEST['perm_'.$key];
-			} else if( $value['type'] == 'email' ) {
-			  $data = trim($_REQUEST['user_'.$key]).'@'.trim($_REQUEST['domain_'.$key]);
-			} else if( $value['type'] == 'resourcepolicy' ) {
-			  $i = 0;
-			  $data = array();
-			  while( isset($_REQUEST['user_'.$key.'_'.$i] ) ) {
-				$data[] = $_REQUEST['user_'.$key.'_'.$i++];
-			  }
-			} else {
-			  $data = $_REQUEST[$key];
-			}
-			$errstr = $v( $this, $key, $data );
-			if( !empty( $errstr ) ) {
-			  $this->errors[] = $errstr;
-			}
-		  }
-		}
+	$vv = $value['validation'];
+	if( !is_array($vv) ) $va = array($vv);
+	else $va = $vv;
+	foreach( $va as $v ) {
+	  //print "validating using $v <br/>";
+	  if( $v == 'notempty' ) {
+	    debug("checking nonemptiness of $key: ".KolabForm::getRequestVar($key)." len=".strlen(trim(KolabForm::getRequestVar($key))));
+	    if( $value['type'] == 'aclselect' ) {
+	      // ignore
+	    } else if( $value['type'] == 'email' ) {
+	      debug('Checking '.$value['name'].': '.$_REQUEST['user_'.$key]);
+	      if( strlen(trim($_REQUEST['user_'.$key])) == 0 ) {
+		$this->errors[] = _('Required field ').$value['name']._(' is empty');
+	      }
+	    } else if( strlen( trim($_REQUEST[$key]) ) == 0 ) {
+	      $this->errors[] = _('Required field ').$value['name']._(' is empty');
+	    }
+	  } else {
+	    if( $value['type'] == 'aclselect' ) {
+	      $data = $_REQUEST['user_'.$key].' '.$_REQUEST['perm_'.$key];
+	    } else if( $value['type'] == 'email' ) {
+	      $data = trim($_REQUEST['user_'.$key]).'@'.trim($_REQUEST['domain_'.$key]);
+	    } else if( $value['type'] == 'resourcepolicy' ) {
+	      $i = 0;
+	      $data = array();
+	      while( isset($_REQUEST['user_'.$key.'_'.$i] ) ) {
+		$data[] = $_REQUEST['user_'.$key.'_'.$i++];
+	      }
+	    } else {
+	      $data = $_REQUEST[$key];
+	    }
+	    $errstr = $v( $this, $key, $data );
+	    if( !empty( $errstr ) ) {
+	      $this->errors[] = $errstr;
+	    }
+	  }
+	}
       }
     }
     //print_r( $this->errors );
@@ -395,35 +396,35 @@
   function setValues() {
     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);
-	  } 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;
+	$this->entries[$k]['user'] = trim($this->value('user_'.$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] );
+	$this->entries[$k]['value'] = isset( $_REQUEST[$k] );
       } else if( $this->entries[$k]['type'] == 'checklist' ) {
-		$this->entries[$k]['value'] = $_REQUEST[$k];
+	$this->entries[$k]['value'] = $_REQUEST[$k];
       } else if( $this->entries[$k]['type'] == 'password' ) {
-		$this->entries[$k]['value'] = $this->value($k);		
-	  } else if( $this->entries[$k]['type'] == 'email' ) {
-		$this->entries[$k]['value'] = trim($this->value('user_'.$k)).'@'.trim($this->value('domain_'.$k));
+	$this->entries[$k]['value'] = $this->value($k);		
+      } else if( $this->entries[$k]['type'] == 'email' ) {
+	$this->entries[$k]['value'] = trim($this->value('user_'.$k)).'@'.trim($this->value('domain_'.$k));
       } else {
-		$this->entries[$k]['value'] = trim($this->value($k));
+	$this->entries[$k]['value'] = trim($this->value($k));
       }
     }    
   }
 
   /* static */ function getRequestVar($var, $default = false)
   {
-	if( isset($_REQUEST[$var]) ) return $_REQUEST[$var];
-	else return $default;
+    if( isset($_REQUEST[$var]) ) return $_REQUEST[$var];
+    else return $default;
   }
 
 
@@ -435,12 +436,12 @@
 };
 
 /*
-  Local variables:
-  mode: php
-  indent-tabs-mode: t
-  tab-width: 4
-  buffer-file-coding-system: utf-8
-  End:
-  vim:encoding=utf-8:
- */
+ Local variables:
+ mode: php
+ indent-tabs-mode: t
+ tab-width: 4
+ buffer-file-coding-system: utf-8
+ End:
+ vim:encoding=utf-8:
+*/
 ?>





More information about the commits mailing list