<commit_before><?
/**
 * Create a new member for testing
 *
 * This file has to be removed in live environment!
 *
 * @author <NAME> <<EMAIL>>
 * @package Basisentscheid
 */


require "inc/common_http.php";

Login::logout();


if ($action) {
	switch ($action) {
	case "create":

		$member = new Member;
		$member->invite = Login::generate_token(24);
		$member->eligible = true;
		$member->verified = true;
		$member->create();

		// become member of ngroups
		if (!empty($_POST['ngroups'])) {
			foreach ( $_POST['ngroups'] as $ngroup ) {
				DB::insert("member_ngroup", array('member'=>$member->id, 'ngroup'=>$ngroup));
			}
		}

		redirect("register.php?invite=".$member->invite);

	default:
		warning(_("Unknown action"));
		redirect();
	}
}


html_head(_("Create new member"));

?>
<section class="help"><p><?=_("In this demo or test installation you can just create a member account by yourself. Next you will be forwarded to the registration, where you can register yourself with this account.")?></p></section>
<?

form(BN);
echo _("Groups of the new member")?>:<br><?
input_hidden("action", "create");
$sql = "SELECT * FROM ngroup WHERE active=TRUE";
$result = DB::query($sql);
while ( $ngroup = DB::fetch_object($result, "Ngroup") ) {
	input_checkbox("ngroups[]", $ngroup->id, true);
	echo $ngroup->name;
	?><br><?
}
input_submit(_("Create new member"));
form_end();

html_foot();
<commit_msg>ignore invalid groups<commit_after><?
/**
 * Create a new member for testing
 *
 * This file has to be removed in live environment!
 *
 * @author <NAME> <<EMAIL>>
 * @package Basisentscheid
 */


require "inc/common_http.php";

Login::logout();


if ($action) {
	switch ($action) {
	case "create":

		$member = new Member;
		$member->invite = Login::generate_token(24);
		$member->eligible = true;
		$member->verified = true;
		$member->create();

		// become member of ngroups
		if (!empty($_POST['ngroups'])) {
			foreach ( $_POST['ngroups'] as $ngroup ) {
				$ngroup_int = intval($ngroup);
				if (!$ngroup_int or $ngroup_int!=$ngroup) continue;
				DB::insert("member_ngroup", array('member'=>$member->id, 'ngroup'=>$ngroup_int));
			}
		}

		redirect("register.php?invite=".$member->invite);

	default:
		warning(_("Unknown action"));
		redirect();
	}
}


html_head(_("Create new member"));

?>
<section class="help"><p><?=_("In this demo or test installation you can just create a member account by yourself. Next you will be forwarded to the registration, where you can register yourself with this account.")?></p></section>
<?

form(BN);
echo _("Groups of the new member")?>:<br><?
input_hidden("action", "create");
$sql = "SELECT * FROM ngroup WHERE active=TRUE";
$result = DB::query($sql);
while ( $ngroup = DB::fetch_object($result, "Ngroup") ) {
	input_checkbox("ngroups[]", $ngroup->id, true);
	echo $ngroup->name;
	?><br><?
}
input_submit(_("Create new member"));
form_end();

html_foot();

{'fraction_non_alphanumeric': 0.1895424836601307, 'fraction_numerical': 0.0013759889920880633, 'mean_word_length': 4.874747474747474, 'pattern_counts': {'":': 2, '<': 31, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3170576', 'n_tokens_mistral': 1010, 'n_tokens_neox': 958, 'n_words': 259}