diff --git a/e107_core/shortcodes/batch/signup_shortcodes.php b/e107_core/shortcodes/batch/signup_shortcodes.php index d52e5a4ca..6aed97812 100755 --- a/e107_core/shortcodes/batch/signup_shortcodes.php +++ b/e107_core/shortcodes/batch/signup_shortcodes.php @@ -348,40 +348,37 @@ class signup_shortcodes extends e_shortcode function sc_signup_userclass_subscribe() { - global $pref, $e_userclass, $USERCLASS_SUBSCRIBE_START, $USERCLASS_SUBSCRIBE_END, $signupData; - $ret = ""; + $pref = e107::pref('core'); + // global $pref, $USERCLASS_SUBSCRIBE_START, $USERCLASS_SUBSCRIBE_END, $signupData; - if($pref['signup_option_class']) + if(empty($pref['signup_option_class'])) { - if (!is_object($e_userclass)) - { - require_once(e_HANDLER.'userclass_class.php'); - $e_userclass = new user_class; - } - $ucList = $e_userclass->get_editable_classes(); // List of classes which this user can edit - $ret = ''; - if(!$ucList) return; - -/* - function show_signup_class($treename, $classnum, $current_value, $nest_level) - { - global $USERCLASS_SUBSCRIBE_ROW, $e_userclass, $tp; - $tmp = explode(',',$current_value); - $search = array('{USERCLASS_ID}', '{USERCLASS_NAME}', '{USERCLASS_DESCRIPTION}', '{USERCLASS_INDENT}', '{USERCLASS_CHECKED}'); - $replace = array($classnum, $tp->toHTML($e_userclass->uc_get_classname($classnum), FALSE, 'defs'), - $tp->toHTML($e_userclass->uc_get_classdescription($classnum), FALSE, 'defs'), " style='text-indent:".(1.2*$nest_level)."em'", - ( in_array($classnum, $tmp) ? " checked='checked'" : '')); - return str_replace($search, $replace, $USERCLASS_SUBSCRIBE_ROW); - }*/ - - $ret = $USERCLASS_SUBSCRIBE_START; - $ret .= $e_userclass->vetted_tree('class',array($this,'show_signup_class'),varset($signupData['user_class'],''),'editable, no-excludes'); - $ret .= $USERCLASS_SUBSCRIBE_END; - return $ret; + return false; } + + $uc = e107::getUserClass(); + + $ucList = $uc->get_editable_classes(e_UC_PUBLIC, true); // This is signup so display only 'editable by public' classes. + + if(empty($ucList)) return false; + + + $text = ''; + foreach($ucList as $classNum) + { + $text .= $this->show_signup_class($classNum, 1); // checked by default. + } + + return $text; + + + + // return $uc->vetted_tree('class', array($this,'show_signup_class'), varset($signupData['user_class'],''),'editable, no-excludes'); + + } - function show_signup_class($treename, $classnum, $current_value, $nest_level) + private function show_signup_class( $classnum, $current_value='', $nest_level=0) { $tp = e107::getParser(); $uc = e107::getUserClass(); @@ -390,7 +387,7 @@ class signup_shortcodes extends e_shortcode if(deftrue('BOOTSTRAP')) { - $text = "
"; + $text = "
"; $label = $tp->toHTML($uc->getName($classnum),false, 'defs'); $diz = $tp->toHTML($uc->getDescription($classnum),false,'defs'); $text .= $frm->checkbox('class[]', $classnum, $current_value, array('label'=>$label,'title'=> $diz, 'class'=>'e-tip')); diff --git a/e107_core/templates/signup_template.php b/e107_core/templates/signup_template.php index d3b000080..1e6043bb0 100755 --- a/e107_core/templates/signup_template.php +++ b/e107_core/templates/signup_template.php @@ -181,6 +181,12 @@ $sc_style['SIGNUP_PASSWORD2']['pre'] = " $sc_style['SIGNUP_PASSWORD2']['post'] = " "; +$sc_style['SIGNUP_USERCLASS_SUBSCRIBE']['pre'] = " + ".LAN_SIGNUP_113." + "; +$sc_style['SIGNUP_USERCLASS_SUBSCRIBE']['post'] = " + "; + if(!defined($COPPA_TEMPLATE)) { diff --git a/e107_languages/English/lan_signup.php b/e107_languages/English/lan_signup.php index e5734da29..d1a6548c6 100644 --- a/e107_languages/English/lan_signup.php +++ b/e107_languages/English/lan_signup.php @@ -152,5 +152,5 @@ define("LAN_SIGNUP_110", "Your full name"); define("LAN_SIGNUP_111", "Enter a URL to your image or choose an existing avatar."); define("LAN_SIGNUP_112", "You are currently logged in as Main Admin."); +define("LAN_SIGNUP_113", "Subscription(s)"); -?> \ No newline at end of file diff --git a/signup.php b/signup.php index 58009386b..d3775c6c3 100644 --- a/signup.php +++ b/signup.php @@ -636,6 +636,14 @@ if (isset($_POST['register']) && intval($pref['user_reg']) === 1) $_POST['password2'] = $_POST['password1']; } + // posted class subscription - check it's only from the public classes. + if(!empty($_POST['class'])) + { + $publicClasses = e107::getUserClass()->get_editable_classes(e_UC_PUBLIC, true); + $_POST['class'] = array_intersect($publicClasses, $_POST['class']); + unset($publicClasses); + } + // Now validate everything $allData = validatorClass::validateFields($_POST,$userMethods->userVettingInfo, TRUE); // Do basic validation validatorClass::checkMandatory('user_name,user_loginname', $allData); // Check for missing fields (email done in userValidation() ) @@ -815,7 +823,12 @@ if (isset($_POST['register']) && intval($pref['user_reg']) === 1) // The user_class, user_perms, user_prefs, user_realm fields don't have default value, // so we put apropriate ones, otherwise - broken DB Insert - $allData['data']['user_class'] = ''; + + if(empty($allData['data']['user_class'])) + { + $allData['data']['user_class'] = ''; + } + $allData['data']['user_perms'] = ''; $allData['data']['user_prefs'] = ''; $allData['data']['user_realm'] = '';