Chris@76: array('AdminRegister', 'moderate_forum'), Chris@76: 'agreement' => array('EditAgreement', 'admin_forum'), Chris@76: 'reservednames' => array('SetReserve', 'admin_forum'), Chris@76: 'settings' => array('ModifyRegistrationSettings', 'admin_forum'), Chris@76: ); Chris@76: Chris@76: // Work out which to call... Chris@76: $context['sub_action'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('moderate_forum') ? 'register' : 'settings'); Chris@76: Chris@76: // Must have sufficient permissions. Chris@76: isAllowedTo($subActions[$context['sub_action']][1]); Chris@76: Chris@76: // Loading, always loading. Chris@76: loadLanguage('Login'); Chris@76: loadTemplate('Register'); Chris@76: Chris@76: // Next create the tabs for the template. Chris@76: $context[$context['admin_menu_name']]['tab_data'] = array( Chris@76: 'title' => $txt['registration_center'], Chris@76: 'help' => 'registrations', Chris@76: 'description' => $txt['admin_settings_desc'], Chris@76: 'tabs' => array( Chris@76: 'register' => array( Chris@76: 'description' => $txt['admin_register_desc'], Chris@76: ), Chris@76: 'agreement' => array( Chris@76: 'description' => $txt['registration_agreement_desc'], Chris@76: ), Chris@76: 'reservednames' => array( Chris@76: 'description' => $txt['admin_reserved_desc'], Chris@76: ), Chris@76: 'settings' => array( Chris@76: 'description' => $txt['admin_settings_desc'], Chris@76: ) Chris@76: ) Chris@76: ); Chris@76: Chris@76: // Finally, get around to calling the function... Chris@76: $subActions[$context['sub_action']][0](); Chris@76: } Chris@76: Chris@76: // This function allows the admin to register a new member by hand. Chris@76: function AdminRegister() Chris@76: { Chris@76: global $txt, $context, $sourcedir, $scripturl, $smcFunc; Chris@76: Chris@76: if (!empty($_POST['regSubmit'])) Chris@76: { Chris@76: checkSession(); Chris@76: Chris@76: foreach ($_POST as $key => $value) Chris@76: if (!is_array($_POST[$key])) Chris@76: $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); Chris@76: Chris@76: $regOptions = array( Chris@76: 'interface' => 'admin', Chris@76: 'username' => $_POST['user'], Chris@76: 'email' => $_POST['email'], Chris@76: 'password' => $_POST['password'], Chris@76: 'password_check' => $_POST['password'], Chris@76: 'check_reserved_name' => true, Chris@76: 'check_password_strength' => false, Chris@76: 'check_email_ban' => false, Chris@76: 'send_welcome_email' => isset($_POST['emailPassword']) || empty($_POST['password']), Chris@76: 'require' => isset($_POST['emailActivate']) ? 'activation' : 'nothing', Chris@76: 'memberGroup' => empty($_POST['group']) || !allowedTo('manage_membergroups') ? 0 : (int) $_POST['group'], Chris@76: ); Chris@76: Chris@76: require_once($sourcedir . '/Subs-Members.php'); Chris@76: $memberID = registerMember($regOptions); Chris@76: if (!empty($memberID)) Chris@76: { Chris@76: $context['new_member'] = array( Chris@76: 'id' => $memberID, Chris@76: 'name' => $_POST['user'], Chris@76: 'href' => $scripturl . '?action=profile;u=' . $memberID, Chris@76: 'link' => '' . $_POST['user'] . '', Chris@76: ); Chris@76: $context['registration_done'] = sprintf($txt['admin_register_done'], $context['new_member']['link']); Chris@76: } Chris@76: } Chris@76: Chris@76: // Basic stuff. Chris@76: $context['sub_template'] = 'admin_register'; Chris@76: $context['page_title'] = $txt['registration_center']; Chris@76: Chris@76: // Load the assignable member groups. Chris@76: if (allowedTo('manage_membergroups')) Chris@76: { Chris@76: $request = $smcFunc['db_query']('', ' Chris@76: SELECT group_name, id_group Chris@76: FROM {db_prefix}membergroups Chris@76: WHERE id_group != {int:moderator_group} Chris@76: AND min_posts = {int:min_posts}' . (allowedTo('admin_forum') ? '' : ' Chris@76: AND id_group != {int:admin_group} Chris@76: AND group_type != {int:is_protected}') . ' Chris@76: AND hidden != {int:hidden_group} Chris@76: ORDER BY min_posts, CASE WHEN id_group < {int:newbie_group} THEN id_group ELSE 4 END, group_name', Chris@76: array( Chris@76: 'moderator_group' => 3, Chris@76: 'min_posts' => -1, Chris@76: 'admin_group' => 1, Chris@76: 'is_protected' => 1, Chris@76: 'hidden_group' => 2, Chris@76: 'newbie_group' => 4, Chris@76: ) Chris@76: ); Chris@76: $context['member_groups'] = array(0 => $txt['admin_register_group_none']); Chris@76: while ($row = $smcFunc['db_fetch_assoc']($request)) Chris@76: $context['member_groups'][$row['id_group']] = $row['group_name']; Chris@76: $smcFunc['db_free_result']($request); Chris@76: } Chris@76: else Chris@76: $context['member_groups'] = array(); Chris@76: } Chris@76: Chris@76: // I hereby agree not to be a lazy bum. Chris@76: function EditAgreement() Chris@76: { Chris@76: global $txt, $boarddir, $context, $modSettings, $smcFunc, $settings; Chris@76: Chris@76: // By default we look at agreement.txt. Chris@76: $context['current_agreement'] = ''; Chris@76: Chris@76: // Is there more than one to edit? Chris@76: $context['editable_agreements'] = array( Chris@76: '' => $txt['admin_agreement_default'], Chris@76: ); Chris@76: Chris@76: // Get our languages. Chris@76: getLanguages(); Chris@76: Chris@76: // Try to figure out if we have more agreements. Chris@76: foreach ($context['languages'] as $lang) Chris@76: { Chris@76: if (file_exists($boarddir . '/agreement.' . $lang['filename'] . '.txt')) Chris@76: { Chris@76: $context['editable_agreements']['.' . $lang['filename']] = $lang['name']; Chris@76: // Are we editing this? Chris@76: if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) Chris@76: $context['current_agreement'] = '.' . $lang['filename']; Chris@76: } Chris@76: } Chris@76: Chris@76: if (isset($_POST['agreement'])) Chris@76: { Chris@76: checkSession(); Chris@76: Chris@76: // Off it goes to the agreement file. Chris@76: $fp = fopen($boarddir . '/agreement' . $context['current_agreement'] . '.txt', 'w'); Chris@76: fwrite($fp, str_replace("\r", '', $_POST['agreement'])); Chris@76: fclose($fp); Chris@76: Chris@76: updateSettings(array('requireAgreement' => !empty($_POST['requireAgreement']))); Chris@76: } Chris@76: Chris@76: $context['agreement'] = file_exists($boarddir . '/agreement' . $context['current_agreement'] . '.txt') ? htmlspecialchars(file_get_contents($boarddir . '/agreement' . $context['current_agreement'] . '.txt')) : ''; Chris@76: $context['warning'] = is_writable($boarddir . '/agreement' . $context['current_agreement'] . '.txt') ? '' : $txt['agreement_not_writable']; Chris@76: $context['require_agreement'] = !empty($modSettings['requireAgreement']); Chris@76: Chris@76: $context['sub_template'] = 'edit_agreement'; Chris@76: $context['page_title'] = $txt['registration_agreement']; Chris@76: } Chris@76: Chris@76: // Set reserved names/words.... Chris@76: function SetReserve() Chris@76: { Chris@76: global $txt, $context, $modSettings; Chris@76: Chris@76: // Submitting new reserved words. Chris@76: if (!empty($_POST['save_reserved_names'])) Chris@76: { Chris@76: checkSession(); Chris@76: Chris@76: // Set all the options.... Chris@76: updateSettings(array( Chris@76: 'reserveWord' => (isset($_POST['matchword']) ? '1' : '0'), Chris@76: 'reserveCase' => (isset($_POST['matchcase']) ? '1' : '0'), Chris@76: 'reserveUser' => (isset($_POST['matchuser']) ? '1' : '0'), Chris@76: 'reserveName' => (isset($_POST['matchname']) ? '1' : '0'), Chris@76: 'reserveNames' => str_replace("\r", '', $_POST['reserved']) Chris@76: )); Chris@76: } Chris@76: Chris@76: // Get the reserved word options and words. Chris@76: $modSettings['reserveNames'] = str_replace('\n', "\n", $modSettings['reserveNames']); Chris@76: $context['reserved_words'] = explode("\n", $modSettings['reserveNames']); Chris@76: $context['reserved_word_options'] = array(); Chris@76: $context['reserved_word_options']['match_word'] = $modSettings['reserveWord'] == '1'; Chris@76: $context['reserved_word_options']['match_case'] = $modSettings['reserveCase'] == '1'; Chris@76: $context['reserved_word_options']['match_user'] = $modSettings['reserveUser'] == '1'; Chris@76: $context['reserved_word_options']['match_name'] = $modSettings['reserveName'] == '1'; Chris@76: Chris@76: // Ready the template...... Chris@76: $context['sub_template'] = 'edit_reserved_words'; Chris@76: $context['page_title'] = $txt['admin_reserved_set']; Chris@76: } Chris@76: Chris@76: // This function handles registration settings, and provides a few pretty stats too while it's at it. Chris@76: function ModifyRegistrationSettings($return_config = false) Chris@76: { Chris@76: global $txt, $context, $scripturl, $modSettings, $sourcedir; Chris@76: Chris@76: // This is really quite wanting. Chris@76: require_once($sourcedir . '/ManageServer.php'); Chris@76: Chris@76: $config_vars = array( Chris@76: array('select', 'registration_method', array($txt['setting_registration_standard'], $txt['setting_registration_activate'], $txt['setting_registration_approval'], $txt['setting_registration_disabled'])), Chris@76: array('check', 'enableOpenID'), Chris@76: array('check', 'notify_new_registration'), Chris@76: array('check', 'send_welcomeEmail'), Chris@76: '', Chris@76: array('int', 'coppaAge', 'subtext' => $txt['setting_coppaAge_desc'], 'onchange' => 'checkCoppa();'), Chris@76: array('select', 'coppaType', array($txt['setting_coppaType_reject'], $txt['setting_coppaType_approval']), 'onchange' => 'checkCoppa();'), Chris@76: array('large_text', 'coppaPost', 'subtext' => $txt['setting_coppaPost_desc']), Chris@76: array('text', 'coppaFax'), Chris@76: array('text', 'coppaPhone'), Chris@76: ); Chris@76: Chris@76: if ($return_config) Chris@76: return $config_vars; Chris@76: Chris@76: // Setup the template Chris@76: $context['sub_template'] = 'show_settings'; Chris@76: $context['page_title'] = $txt['registration_center']; Chris@76: Chris@76: if (isset($_GET['save'])) Chris@76: { Chris@76: checkSession(); Chris@76: Chris@76: // Are there some contacts missing? Chris@76: if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) Chris@76: fatal_lang_error('admin_setting_coppa_require_contact'); Chris@76: Chris@76: // Post needs to take into account line breaks. Chris@76: $_POST['coppaPost'] = str_replace("\n", '
', empty($_POST['coppaPost']) ? '' : $_POST['coppaPost']); Chris@76: Chris@76: saveDBSettings($config_vars); Chris@76: Chris@76: redirectexit('action=admin;area=regcenter;sa=settings'); Chris@76: } Chris@76: Chris@76: $context['post_url'] = $scripturl . '?action=admin;area=regcenter;save;sa=settings'; Chris@76: $context['settings_title'] = $txt['settings']; Chris@76: Chris@76: // Define some javascript for COPPA. Chris@76: $context['settings_post_javascript'] = ' Chris@76: function checkCoppa() Chris@76: { Chris@76: var coppaDisabled = document.getElementById(\'coppaAge\').value == 0; Chris@76: document.getElementById(\'coppaType\').disabled = coppaDisabled; Chris@76: Chris@76: var disableContacts = coppaDisabled || document.getElementById(\'coppaType\').options[document.getElementById(\'coppaType\').selectedIndex].value != 1; Chris@76: document.getElementById(\'coppaPost\').disabled = disableContacts; Chris@76: document.getElementById(\'coppaFax\').disabled = disableContacts; Chris@76: document.getElementById(\'coppaPhone\').disabled = disableContacts; Chris@76: } Chris@76: checkCoppa();'; Chris@76: Chris@76: // Turn the postal address into something suitable for a textbox. Chris@76: $modSettings['coppaPost'] = !empty($modSettings['coppaPost']) ? preg_replace('~
~', "\n", $modSettings['coppaPost']) : ''; Chris@76: Chris@76: prepareDBSettingContext($config_vars); Chris@76: } Chris@76: Chris@76: ?>