summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Wrobel <wrobel@pardus.de>2007-05-24 09:49:58 (GMT)
committerGunnar Wrobel <wrobel@pardus.de>2007-05-24 09:49:58 (GMT)
commitf3df1da2622d7ecdadabac898fb76cd92618826a (patch)
tree70a0320b69aa376facf948494d0d31c90b4ad283
parentc95a456fb40ba6285d3360cf27b44b1212ebd145 (diff)
downloadkolab-webadmin-f3df1da2622d7ecdadabac898fb76cd92618826a.tar.gz
Fixed kolab/issue1620 (https://intevation.de/roundup/kolab/issue1620)
-rw-r--r--ChangeLog5
-rw-r--r--php/admin/include/form.class.php599
2 files changed, 305 insertions, 299 deletions
diff --git a/ChangeLog b/ChangeLog
index 9f0443c..5fd6e74 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2007-05-24 Gunnar Wrobel <p@rdus.de>
+ * php/admin/include/form.class.php:
+
+ Fixed
+ kolab/issue1620 (https://intevation.de/roundup/kolab/issue1620)
+
* www/admin/user/user.php.in:
* www/admin/maintainer/maintainer.php.in:
* www/admin/domainmaintainer/domainmaintainer.php.in:
diff --git a/php/admin/include/form.class.php b/php/admin/include/form.class.php
index 5185093..8de1437 100644
--- a/php/admin/include/form.class.php
+++ b/php/admin/include/form.class.php
@@ -51,22 +51,23 @@ class KolabForm {
*/
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 @@ class KolabForm {
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 @@ class KolabForm {
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 @@ class KolabForm {
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 @@ class KolabForm {
};
/*
- 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:
+*/
?>