summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteffen Hansen <steffen@kdab.com>2006-12-08 21:12:58 (GMT)
committerSteffen Hansen <steffen@kdab.com>2006-12-08 21:12:58 (GMT)
commitaec8d397c349950f7a1de7cb0d38653b88c8ef6e (patch)
tree2af39afde523be9126ff2633643d090a955719b5
parente9759362fb99778307843d3652303fe31537d37e (diff)
downloadkolab-webadmin-2.0-stable.tar.gz
Fix for issue1418 (Field customisation issue)2.0-stable
-rw-r--r--php/admin/include/form.class.php28
-rw-r--r--www/admin/style.css6
-rw-r--r--www/admin/user/user.php112
3 files changed, 86 insertions, 60 deletions
diff --git a/php/admin/include/form.class.php b/php/admin/include/form.class.php
index 83aa2e7..20b893c 100644
--- a/php/admin/include/form.class.php
+++ b/php/admin/include/form.class.php
@@ -44,6 +44,18 @@ class KolabForm {
if( !isset( $value['attrs'] ) ) $this->entries[$key]['attrs'] = '';
}
}
+
+ /*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() {
$str = '<div class="contentform">';
@@ -69,7 +81,6 @@ class KolabForm {
// Default is text
$value['type'] = 'text';
}
-
switch( $value['type'] ) {
case 'hidden': continue;
case 'password':
@@ -88,14 +99,14 @@ class KolabForm {
$str .= '<td><input name="'.$key.'" type="'.$value['type'].'" value="'.MySmarty::htmlentities($value['value']).'" '
.MySmarty::htmlentities($value['attrs']).' size="'.$size.'" /></td>';
}
- $str .= '<td>'.$value['comment'].'</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>'.$value['comment'].'</td>';
+ $str .= '<td>'.KolabForm::comment_helper($value).'</td>';
$str .= '</tr>'."\n";
break;
case 'textarea':
@@ -106,7 +117,7 @@ class KolabForm {
} else {
$str .= '<td><textarea name="'.$key.'" rows="5" cols="'.$size.'" '.$value['attrs'].' onkeypress="javascript:textareakeypress()">'.MySmarty::htmlentities($value['value']).'</textarea></td>';
}
- $str .= '<td>'.$value['comment'].'</td>';
+ $str .= '<td>'.KolabForm::comment_helper($value).'</td>';
$str .= '</tr>'."\n";
break;
case 'checkbox':
@@ -117,7 +128,7 @@ class KolabForm {
} else {
$str .= '<td><input name="'.$key.'" type="'.$value['type'].'" value="on" '.($value['value']?'checked':'').' '.$value['attrs'].' /></td>';
}
- $str .= '<td>'.$value['comment'].'</td>';
+ $str .= '<td>'.KolabForm::comment_helper($value).'</td>';
$str .= '</tr>'."\n";
break;
case 'select':
@@ -137,7 +148,7 @@ class KolabForm {
$str .= '</select>';
$str .= '</td>';
}
- $str .= '<td>'.$value['comment'].'</td>';
+ $str .= '<td>'.KolabForm::comment_helper($value).'</td>';
$str .= '</tr>'."\n";
break;
case 'aclselect': // Special Kolab entry for ACLs
@@ -168,7 +179,7 @@ class KolabForm {
$str .= '</select>';
$str .= '</td>';
}
- $str .= '<td>'.$value['comment'].'</td>';
+ $str .= '<td>'.KolabForm::comment_helper($value).'</td>';
$str .= '</tr>'."\n";
break;
case 'resourcepolicy': // Special Kolab entry for group/resource policies
@@ -218,7 +229,7 @@ class KolabForm {
}
}
$str .= '</table></td>';
- $str .= '<td>'.$value['comment'].'</td>';
+ $str .= '<td>'.KolabForm::comment_helper($value).'</td>';
$str .= '</tr>'."\n";
break;
}
@@ -235,6 +246,7 @@ class KolabForm {
}
}
$str .= '</form>';
+ $str .= '<div class="required_asterisk">'._('* Required field.').'</div>';
$str .= '</div>';
return $str;
}
diff --git a/www/admin/style.css b/www/admin/style.css
index e8c6047..dbbd8eb 100644
--- a/www/admin/style.css
+++ b/www/admin/style.css
@@ -183,3 +183,9 @@ th {
border: solid 1px black;
padding: .2em .5em .2em .5em;
}
+
+.required_asterisk {
+ color: red;
+ font-size: 80%;
+ text-align: right;
+}
diff --git a/www/admin/user/user.php b/www/admin/user/user.php
index ff31b7a..c1f1c4b 100644
--- a/www/admin/user/user.php
+++ b/www/admin/user/user.php
@@ -178,6 +178,7 @@ function apply_attributeaccess( &$entries ) {
if( $attributeaccess[$akey] == 'ro' ) {
$entries[$key]['attrs'] = 'readonly';
} else if( $attributeaccess[$akey] == 'hidden' ) {
+ //$entries[$key]['attrs'] = 'hidden';
unset($entries[$key]);
} else if( $attributeaccess[$akey] == 'mandatory' ) {
if( isset( $entries[$key]['validation'] ) ) {
@@ -211,68 +212,74 @@ function fill_form_for_modify( &$form, $dn, &$ldap_object ) {
else $mail = $ldap_object['mail'];
if (is_array($ldap_object['uid'])) $uid = $ldap_object['uid'][0];
else $uid = $ldap_object['uid'];
- $form->entries['givenname']['value'] = $givenname;
- $form->entries['sn']['value'] = $sn;
- $form->entries['password_0']['value'] = '';
- $form->entries['password_1']['value'] = '';
- $form->entries['mail']['value'] = $mail;
- $form->entries['mail']['attrs'] = 'readonly';
- $form->entries['uid']['value'] = $uid;
-
+ if(array_key_exists('givenname',$form->entries)) $form->entries['givenname']['value'] = $givenname;
+ if(array_key_exists('sn',$form->entries)) $form->entries['sn']['value'] = $sn;
+ if(array_key_exists('password_0',$form->entries)) $form->entries['password_0']['value'] = '';
+ if(array_key_exists('password_1',$form->entries)) $form->entries['password_1']['value'] = '';
+ if(array_key_exists('mail',$form->entries)) $form->entries['mail']['value'] = $mail;
+ if(array_key_exists('mail',$form->entries)) $form->entries['mail']['attrs'] = 'readonly';
+ if(array_key_exists('uid',$form->entries)) $form->entries['uid']['value'] = $uid;
// accttype
$dncomp = split( ',', $dn );
- if( in_array('cn=groups',$dncomp) ) {
- $form->entries['accttype']['value'] = 2;
- } else if( in_array('cn=resources',$dncomp) ) {
- $form->entries['accttype']['value'] = 3;
- } else if( in_array('cn=internal',$dncomp) ) {
- $form->entries['accttype']['value'] = 1;
- } else {
- $form->entries['accttype']['value'] = 0;
+ if(array_key_exists('acctype',$form->entries)) {
+ if( in_array('cn=groups',$dncomp) ) {
+ $form->entries['accttype']['value'] = 2;
+ } else if( in_array('cn=resources',$dncomp) ) {
+ $form->entries['accttype']['value'] = 3;
+ } else if( in_array('cn=internal',$dncomp) ) {
+ $form->entries['accttype']['value'] = 1;
+ } else {
+ $form->entries['accttype']['value'] = 0;
+ }
+ if( $auth->group() == 'user' ) $form->entries['accttype']['attrs'] = 'readonly';
}
- if( $auth->group() == 'user' ) $form->entries['accttype']['attrs'] = 'readonly';
// Automatic invitation handling
- $policies = array();
- for( $i = 0; $i < $ldap_object['kolabInvitationPolicy']['count']; $i++ ) {
- $resact = $ldap_object['kolabInvitationPolicy'][$i];
- debug("resact=$resact");
- if( ereg( '(.*):(.*)', trim($resact), $regs ) ) {
- $user = trim($regs[1]);
- $pol = trim($regs[2]);
- if( empty($user) ) continue;
- } else {
- $user = 'anyone';
- $pol = trim($resact);
- }
- if( $form->entries['accttype']['value'] == 1 ) {
- // default for groups
- $pol = policy2number( $pol, 3 /*ACT_MANUAL_IF_CONFLICTS*/ );
- } else {
- // default for resources
- $pol = policy2number( $pol, 2 /*ACT_REJECT_IF_CONFLICTS*/ );
- }
- $policies[$user] = $pol;
+ if(array_key_exists('kolabinvitationpolicy',$form->entries)) {
+ $policies = array();
+ for( $i = 0; $i < $ldap_object['kolabInvitationPolicy']['count']; $i++ ) {
+ $resact = $ldap_object['kolabInvitationPolicy'][$i];
+ debug("resact=$resact");
+ if( ereg( '(.*):(.*)', trim($resact), $regs ) ) {
+ $user = trim($regs[1]);
+ $pol = trim($regs[2]);
+ if( empty($user) ) continue;
+ } else {
+ $user = 'anyone';
+ $pol = trim($resact);
+ }
+ if( $form->entries['accttype']['value'] == 1 ) {
+ // default for groups
+ $pol = policy2number( $pol, 3 /*ACT_MANUAL_IF_CONFLICTS*/ );
+ } else {
+ // default for resources
+ $pol = policy2number( $pol, 2 /*ACT_REJECT_IF_CONFLICTS*/ );
+ }
+ $policies[$user] = $pol;
+ }
+ if( !isset( $policies['anyone'] ) ) $policies['anyone'] = 4 /*ACT_MANUAL*/;
+ $form->entries['kolabinvitationpolicy']['policies'] = $policies;
}
- if( !isset( $policies['anyone'] ) ) $policies['anyone'] = 4 /*ACT_MANUAL*/;
- $form->entries['kolabinvitationpolicy']['policies'] = $policies;
foreach( array( 'title', 'o', 'ou', 'roomNumber', 'street',
'postOfficeBox', 'postalCode', 'l', 'c',
'telephoneNumber', 'facsimileTelephoneNumber' ) as $attr ) {
+ if(!array_key_exists($attr.'_0',$form->entries)) continue;
if (is_array($ldap_object[$attr])) $v = $ldap_object[$attr][0];
else $v = $ldap_object[$attr];
$form->entries[$attr.'_0']['value'] = $v;
}
// alias
- if (is_array($ldap_object['alias'])) {
- $arr = $ldap_object['alias'];
- unset( $arr['count'] );
- $v = join("\n", $arr );
+ if(array_key_exists('alias',$form->entries)) {
+ if (is_array($ldap_object['alias'])) {
+ $arr = $ldap_object['alias'];
+ unset( $arr['count'] );
+ $v = join("\n", $arr );
+ }
+ else $v = "";
+ $form->entries['alias']['value'] = $v;
}
- else $v = "";
- $form->entries['alias']['value'] = $v;
// kolabdelegate
if (is_array($ldap_object['kolabDelegate'])) {
@@ -281,14 +288,15 @@ function fill_form_for_modify( &$form, $dn, &$ldap_object ) {
$v = join("\n", $arr );
}
else $v = "";
- $form->entries['kolabdelegate']['value'] = $v;
+ if(array_key_exists('kolabdelegate',$form->entries)) $form->entries['kolabdelegate']['value'] = $v;
// kolabhomeserver
- if( is_array($ldap_object['kolabHomeServer']) ) {
- $form->entries['kolabhomeserver']['value'] = $ldap_object['kolabHomeServer'][0];
+ if(array_key_exists('kolabhomeserver',$form->entries)) {
+ if( is_array($ldap_object['kolabHomeServer']) ) {
+ $form->entries['kolabhomeserver']['value'] = $ldap_object['kolabHomeServer'][0];
+ }
+ $form->entries['kolabhomeserver']['attrs'] = 'readonly';
}
- $form->entries['kolabhomeserver']['attrs'] = 'readonly';
-
$form->entries['action']['value'] = 'save';
// userquota
@@ -307,8 +315,8 @@ function fill_form_for_modify( &$form, $dn, &$ldap_object ) {
if( is_array( $ldap_object['kolabFreeBusyFuture'] ) )
$freebusyfuture = $ldap_object['kolabFreeBusyFuture'][0];
else $freebusyfuture = $ldap_object['kolabFreeBusyFuture'];
+ $form->entries['kolabFreeBusyFuture_0']['value'] = $freebusyfuture;
}
- $form->entries['kolabFreeBusyFuture_0']['value'] = $freebusyfuture;
}
/**** Authentication etc. ***/
@@ -504,7 +512,7 @@ switch( $action ) {
}
if ($count > 0) $ldap_object[$attr] = $args;
elseif (!empty($_POST[$key])) $ldap_object[$attr] = $_POST[$key];
- else $ldap_object[$attr] = array();
+ else/*if (in_array($key,$_POST))*/ $ldap_object[$attr] = array();
}
{
// Handle group/resource policies