diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/views/Template.class.php | 30 | ||||
-rw-r--r-- | src/views/pages/users/index.html.php | 4 | ||||
-rw-r--r-- | src/views/pages/users/individual.html.php | 9 |
3 files changed, 39 insertions, 4 deletions
diff --git a/src/views/Template.class.php b/src/views/Template.class.php index b128ef3..ba51a2f 100644 --- a/src/views/Template.class.php +++ b/src/views/Template.class.php @@ -254,9 +254,35 @@ class Template { "\n".$this->tabs()."\t". $this->inputStr('password', $id.'_verify', $default,$lock)); } - public function inputBool($name, $value, $label, $default=FALSE, $lock=FALSE) { + public function inputBool($id, $label, $hint='', $default=FALSE, $lock=FALSE) { + $tag = ''; + if ($lock) $tag.= "readonly='readonly' "; + if ($default) $tag.= "checked='checked' "; + return $this->input($id, $label, $hint, + "<input type='hidden' name='$id' value='false' />". + "<input type='checkbox' id='$id' name='$id' value='true' $tag>"); + + $attrib = array('type'=>'checkbox', + 'id'=>$id, + 'name'=>$name.'[]', + 'value'=>$value); + if ($default) $attrib['checked']='checked'; + if ($lock ) $attrib['readonly']='readonly'; + + $str = $this->openTag('li'); + $str.= $this->tag('input', $attrib); + $str.= $this->tag('label', array('for'=>$id), $label); + $str.= $this->closeTag('li'); + + if ($this->ret) return $str; + echo $str; + + } + + public function inputBoolArray($name, $value, $label, $default=FALSE, $lock=FALSE) { + $id = $name.'_'.$value; $attrib = array('type'=>'checkbox', - 'id'=>$name.'_'.$value, + 'id'=>$id, 'name'=>$name.'[]', 'value'=>$value); if ($default) $attrib['checked']='checked'; diff --git a/src/views/pages/users/index.html.php b/src/views/pages/users/index.html.php index c268c87..ade4dea 100644 --- a/src/views/pages/users/index.html.php +++ b/src/views/pages/users/index.html.php @@ -23,6 +23,8 @@ foreach ($users as $user) { $t->openTag('tr'); foreach ($attribs as $attrib) { + $t->openTag('td'); + $props = $user[$attrib['key']]; $value = $props['value']; @@ -36,6 +38,7 @@ foreach ($users as $user) { if ($bool) $arr['disabled'] = $disabled; } if ($bool) { + $t->tag('input', array('type'=>'hidden', 'name'=>$post_key, 'value'=>'false')); if ($value==true) { $arr['checked'] = 'checked'; } @@ -46,7 +49,6 @@ foreach ($users as $user) { $arr['type'] = 'text'; } - $t->openTag('td'); $t->tag('input', $arr); $t->closeTag('td'); } diff --git a/src/views/pages/users/individual.html.php b/src/views/pages/users/individual.html.php index 9e3048a..6b23e0e 100644 --- a/src/views/pages/users/individual.html.php +++ b/src/views/pages/users/individual.html.php @@ -15,12 +15,19 @@ function inputTextarea($user, $key, $label, $hint='') { !$user->canEdit()); } +function inputBool($user, $key, $label, $hint='') { + global $VARS; $t = $VARS['template']; + $current_setting = $user->getConf($key)=='true'; + $t->inputBool("user_$key", $label, $hint, $current_setting, + !$user->canEdit()); +} + function inputArray($user, $key, $arr) { global $VARS; $t = $VARS['template']; $defaults = $user->getConfArray($key); foreach ($arr as $value => $label) { - $t->inputBool($name, $value, $label, + $t->inputBoolArray($key, $value, $label, in_array($value, $defaults), !$user->canEdit()); } } |