<commit_before><?php
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !== false) {
	header('location: index.php');
	exit;
}

$ratingconfiglib = TikiLib::lib('ratingconfig');
$ratinglib = TikiLib::lib('rating');
$access = TikiLib::lib('access');

if ( isset($_REQUEST['test']) && $access->is_machine_request() ) {
	$message = $ratinglib->test_formula($_REQUEST['test'], array( 'type', 'object-id' ));

	$access->output_serialized(
		array(
			'valid' => empty($message),
			'message' => $message,
		)
	);
	exit;
}

if ( isset($_POST['create']) && ! empty($_POST['name']) ) {
	$id = $ratingconfiglib->create_configuration($_POST['name']);
	$access->flash(tr('New configuration created (id %0)', $id));
}

if ( isset($_POST['edit']) ) {
	$ratingconfiglib->update_configuration($_POST['config'], $_POST['name'], $_POST['expiry'], $_POST['formula']);
	$access->flash(tra('Configuration updated.'));
}

$configurations = $ratingconfiglib->get_configurations();

$smarty->assign('configurations', $configurations);

<commit_msg>[REF] admin rating: add filters and feedback, and use ticket system<commit_after><?php
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !== false) {
	header('location: index.php');
	exit;
}

$ratingconfiglib = TikiLib::lib('ratingconfig');
$ratinglib = TikiLib::lib('rating');
$access = TikiLib::lib('access');

if ($access->ticketMatch()) {
	//don't see an input "test" in the forms at include_rating.tpl
	if ( isset($_REQUEST['test']) && $access->is_machine_request() ) {
		$message = $ratinglib->test_formula($_REQUEST['test'], array( 'type', 'object-id' ));

		$access->output_serialized(
			array(
				'valid' => empty($message),
				'message' => $message,
			)
		);
		exit;
	}

	if ( isset($_POST['create']) && ! empty($jitPost->name->text()) ) {
		$id = $ratingconfiglib->create_configuration($jitPost->name->text());
		Feedback::success(tr('New rating configuration %0 created', '<em>' . $jitPost->name->text() . '</em>'), 'session');
	}

	if ( isset($_POST['edit']) ) {
		$ratingconfiglib->update_configuration($jitPost->config->digits(), $jitPost->name->text(),
			$jitPost->expiry->digits(), $jitPost->formula->xss());
		Feedback::success(tr('Rating configuration updated for %0', '<em>' . $jitPost->name->text() . '</em>'), 'session');
	}
}

$configurations = $ratingconfiglib->get_configurations();

$smarty->assign('configurations', $configurations);


{'fraction_non_alphanumeric': 0.20082107423879575, 'fraction_numerical': 0.006500171057133082, 'mean_word_length': 5.526785714285714, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 44, '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': '2608937', 'n_tokens_mistral': 993, 'n_tokens_neox': 934, 'n_words': 212}