diff --git a/e107_admin/userclass2.php b/e107_admin/userclass2.php index d08e89bc7..6294a7ec3 100644 --- a/e107_admin/userclass2.php +++ b/e107_admin/userclass2.php @@ -90,9 +90,9 @@ e107::coreLan('userclass2', true); 'userclass_description' => array('title'=> LAN_DESCRIPTION, 'type' => 'text', 'tab'=>0,'data'=>'str', 'inline'=>true,'width' => 'auto', 'thclass' => 'left', 'writeParms'=>array('size'=>'xxlarge')), 'userclass_type' => array('title'=> LAN_TYPE, 'type' => 'dropdown', 'tab'=>0,'data'=>'int', 'width' => '10%', 'thclass' => 'left', 'class'=>'left' ), 'userclass_editclass' => array('title'=> LAN_MANAGER, 'type' => 'userclass', 'tab'=>0,'data'=>'int', 'width' => 'auto', 'thclass' => 'left', 'writeParms'=>array('classlist'=>'nobody,public,main,admin,classes,matchclass,member, no-excludes')), - 'userclass_visibility' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'tab'=>0,'data'=>'int', 'width' => 'auto', 'thclass' => 'left'), + 'userclass_visibility' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'tab'=>0,'data'=>'int', 'width' => 'auto', 'thclass' => 'left', 'writeParms'=>array()), 'userclass_parent' => array('title'=> LAN_PARENT, 'type' => 'userclass', 'tab'=>0,'data'=>'int', 'width' => 'auto', 'thclass' => 'left', 'writeParms'=>array('classlist'=>'main,admin,nobody,public,classes,matchclass,member, no-excludes')), - 'userclass_perms' => array('title'=> "Perms", 'type' => 'hidden', 'tab'=>0,'data'=>'str', 'width' => 'auto', 'thclass' => 'left'), + 'userclass_perms' => array('title'=> "Perms", 'type' => 'hidden', 'tab'=>0,'data'=>'str', 'width' => 'auto', 'thclass' => 'left', 'writeParms'=>array()), 'options' => array('title'=> LAN_OPTIONS, 'type' => 'method', 'width' => '10%', 'thclass' => 'center last', 'forced'=>TRUE, 'class'=>'right', 'readParms' => array('deleteClass' => e_UC_NOBODY)) ); diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index e0d6b2d33..b17b3f965 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -3147,26 +3147,40 @@ class e_form */ - } - - - - - - + } - function uc_select($name, $current_value, $uc_options, $select_options = array(), $opt_options = array()) + + /** + * @param $name + * @param null $current_value + * @param null $uc_options + * @param array $select_options multiple, default + * @param array $opt_options + * @return string + */ + function uc_select($name, $current_value=null, $uc_options=null, $select_options = array(), $opt_options = array()) { +/* var_dump($name); + var_dump($current_value); +var_dump($uc_options); +var_dump($select_options);*/ + + if(!empty($select_options['multiple']) && substr($name,-1) != ']') { $name .= '[]'; } - if(empty($current_value) && !empty($uc_options)) // make the first in the opt list the default value. + if(($current_value === null || $current_value === '') && !empty($uc_options)) // make the first in the opt list the default value. { $tmp = explode(",", $uc_options); $current_value = e107::getUserClass()->getClassFromKey($tmp[0]); + + if(isset($select_options['default'])) + { + $current_value = (int) $select_options['default']; + } } if(!empty($current_value) && !is_numeric($current_value)) // convert name to id. @@ -3189,7 +3203,11 @@ class e_form unset($tmp); } - return $this->select_open($name, $select_options)."\n".$this->_uc->vetted_tree($name, array($this, '_uc_select_cb'), $current_value, $uc_options, $opt_options)."\n".$this->select_close(); + $text = $this->select_open($name, $select_options)."\n"; + $text .= $this->_uc->vetted_tree($name, array($this, '_uc_select_cb'), $current_value, $uc_options, $opt_options)."\n"; + $text .= $this->select_close(); + + return $text; } // Callback for vetted_tree - Creates the option list for a selection box @@ -5720,7 +5738,7 @@ class e_form $parms['post'] = "".$tp->toGlyph('fa-language')."".varset($parms['post']); $key = $key.'['.e_LANGUAGE.']'; } - + if(empty($value) && !empty($parms['default']) && $attributes['type'] !== 'dropdown') // Allow writeParms to set default value. { $value = $parms['default'];