<commit_before><?php
/**
 * Save informe entity
 *
 * @package Blog
 */

// start a new sticky form session in case of failure
elgg_make_sticky_form('informe');

// save or preview
$save = (bool)get_input('save');

// store errors to pass along
$error = FALSE;
$error_forward_url = REFERER;
$user = elgg_get_logged_in_user_entity();

// edit or create a new entity
$guid = get_input('guid');

$activities = get_input('activities');

if ($guid) {
	$entity = get_entity($guid);
	if (elgg_instanceof($entity, 'object', 'informe') && $entity->canEdit()) {
		$informe = $entity;
	} else {
		register_error(elgg_echo('informe:error:post_not_found'));
		forward(get_input('forward', REFERER));
	}

	// save some data for revisions once we save the new edit
	$revision_text = $informe->description;
	$new_post = $informe->new_post;
} else {
	$informe = new ElggInforme();
	$informe->subtype = 'informe';
	$new_post = TRUE;
}

// set the previous status for the hooks to update the time_created and river entries
$old_status = $informe->status;

// set defaults and required values.

// group this report belongs to
$container_guid = (int)get_input('container_guid');
$group = get_entity($container_guid);

// period for this report
$report_month = strftime('%B %Y', strtotime(get_input('informe_period_y')."-".get_input('informe_period_m')));
$values = array(
	'title' => "Informe del grupo ".$group->name." ($report_month)",
	'informe_period_m' => '',
	'informe_period_y' => '',
	'meeting_pa' => '',
	'meeting_ap' => '',
	'meeting_manager' => '',
	'meeting_building' => '',
	'meeting_date' => '',
	'meeting_place' => '',
	'meeting_assistance' => '',
	'topics' => '',
	'news' => '',
	'requirements' => '',
	'rating' => '',
	'pros' => '',
	'cons' => '',
	'meeting_comments' => '',
	'productiv' => '',
	'other_comments' => '',
	'description' => '',
	'status' => 'draft',
	'access_id' => ACCESS_DEFAULT,
	'comments_on' => 'On',
	'container_guid' => (int)get_input('container_guid'),
);

// fail if a required entity isn't set
$required = array();
if(get_input('status') == 'published') {
	$required = array(
		'title' => '',
		'informe_period_m',
		'informe_period_y',
		'meeting_pa',
		'meeting_ap',
		'meeting_manager',
		'meeting_date',
		'meeting_building',
		'meeting_place',
		'meeting_assistance',
		#'topics',
		#'news',
		#'requirements',
		#'rating',
		#'pros',
		#'cons',
		#'meeting_comments',
		#'productiv',
		#'other_comments'
	);
}
<commit_msg>Add sanity check<commit_after><?php
/**
 * Save informe entity
 *
 * @package Blog
 */

// start a new sticky form session in case of failure
elgg_make_sticky_form('informe');

// save or preview
$save = (bool)get_input('save');

// store errors to pass along
$error = FALSE;
$error_forward_url = REFERER;
$user = elgg_get_logged_in_user_entity();

// edit or create a new entity
$guid = get_input('guid');

$activities = get_input('activities');

if ($guid) {
	$entity = get_entity($guid);
	if (elgg_instanceof($entity, 'object', 'informe') && $entity->canEdit()) {
		$informe = $entity;
	} else {
		register_error(elgg_echo('informe:error:post_not_found'));
		forward(get_input('forward', REFERER));
	}

	// save some data for revisions once we save the new edit
	$revision_text = $informe->description;
	$new_post = $informe->new_post;
} else {
	$informe = new ElggInforme();
	$informe->subtype = 'informe';
	$new_post = TRUE;
}

// set the previous status for the hooks to update the time_created and river entries
$old_status = $informe->status;

// set defaults and required values.

// group this report belongs to
$container_guid = (int)get_input('container_guid');
$group = get_entity($container_guid);

if (!elgg_instanceof($group, 'group')) {
    register_error(elgg_echo('informe:error:nocontainer'));
    forward(REFERRER);
}

// period for this report
$report_month = strftime('%B %Y', strtotime(get_input('informe_period_y')."-".get_input('informe_period_m')));
$values = array(
	'title' => "Informe del grupo ".$group->name." ($report_month)",
	'informe_period_m' => '',
	'informe_period_y' => '',
	'meeting_pa' => '',
	'meeting_ap' => '',
	'meeting_manager' => '',
	'meeting_building' => '',
	'meeting_date' => '',
	'meeting_place' => '',
	'meeting_assistance' => '',
	'topics' => '',
	'news' => '',
	'requirements' => '',
	'rating' => '',
	'pros' => '',
	'cons' => '',
	'meeting_comments' => '',
	'productiv' => '',
	'other_comments' => '',
	'description' => '',
	'status' => 'draft',
	'access_id' => ACCESS_DEFAULT,
	'comments_on' => 'On',
	'container_guid' => $group->guid,
);

// fail if a required entity isn't set
$required = array();
if(get_input('status') == 'published') {
	$required = array(
		'title' => '',
		'informe_period_m',
		'informe_period_y',
		'meeting_pa',
		'meeting_ap',
		'meeting_manager',
		'meeting_date',
		'meeting_building',
		'meeting_place',
		'meeting_assistance',
		#'topics',
		#'news',
		#'requirements',
		#'rating',
		#'pros',
		#'cons',
		#'meeting_comments',
		#'productiv',
		#'other_comments'
	);
}

{'fraction_non_alphanumeric': 0.19568690095846644, 'fraction_numerical': 0.0, 'mean_word_length': 4.963095238095238, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 66, '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': '5182392', 'n_tokens_mistral': 1945, 'n_tokens_neox': 1845, 'n_words': 379}