<commit_before><?php

/**
 * This file contains several functions for retrieving and manipulating calendar events, birthdays and holidays.
 *
 * @name      ElkArte Forum
 * @copyright ElkArte Forum contributors
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause
 *
 * This software is a derived product, based on:
 *
 * Simple Machines Forum (SMF)
 * copyright:	2011 Simple Machines (http://www.simplemachines.org)
 * license:  	BSD, See included LICENSE.TXT for terms and conditions.
 *
 * @version 1.0
 *
 */

if (!defined('ELK'))
	die('No access...');

/**
 * This class's task is to bind the posting of a topic to a calendar event.
 * Used when from the calendar controller the poster is redirected to the post page.
 */
class Calendar_Post_Module
{
	protected static $_make_event = false;

	public static function hooks()
	{
		global $context;

		// Posting an event?
		self::$_make_event = isset($_REQUEST['calendar']);

		$context['make_event'] = self::$_make_event;

		if (self::$_make_event)
			return array(
				array('prepare_post', array('Calendar_Post_Module', 'prepare_post'), array()),
				array('prepare_context', array('Calendar_Post_Module', 'prepare_context'), array()),
				array('before_save_post', array('Calendar_Post_Module', 'before_save_post'), array()),
				array('save_post', array('Calendar_Post_Module', 'save_post'), array()),
			);
		else
			return array();
	}

	public function prepare_post()
	{
		Template_Layers::getInstance()->addAfter('make_event', 'postarea');
	}

	public function before_save_post($post_errors)
	{
		if (!isset($_REQUEST['deleteevent']) && Util::htmltrim($_POST['evtitle']) === '')
			$post_errors->addError('no_event');
	}

	public function save_post($board, $topic)
	{
		global $user_info, $modSettings;

		$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];

		$event = new Calendar_Event($_REQUEST['eventid'], $modSettings);

		try
		{
			$save_data = $event->validate($_POST);
		}<commit_msg>Wrong name of the trigger for the Calendar module in Post controller<commit_after><?php

/**
 * This file contains several functions for retrieving and manipulating calendar events, birthdays and holidays.
 *
 * @name      ElkArte Forum
 * @copyright ElkArte Forum contributors
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause
 *
 * This software is a derived product, based on:
 *
 * Simple Machines Forum (SMF)
 * copyright:	2011 Simple Machines (http://www.simplemachines.org)
 * license:  	BSD, See included LICENSE.TXT for terms and conditions.
 *
 * @version 1.0
 *
 */

if (!defined('ELK'))
	die('No access...');

/**
 * This class's task is to bind the posting of a topic to a calendar event.
 * Used when from the calendar controller the poster is redirected to the post page.
 */
class Calendar_Post_Module
{
	protected static $_make_event = false;

	public static function hooks()
	{
		global $context;

		// Posting an event?
		self::$_make_event = isset($_REQUEST['calendar']);

		$context['make_event'] = self::$_make_event;

		if (self::$_make_event)
			return array(
				array('prepare_post', array('Calendar_Post_Module', 'prepare_post'), array()),
				array('prepare_context', array('Calendar_Post_Module', 'prepare_context'), array()),
				array('before_save_post', array('Calendar_Post_Module', 'before_save_post'), array()),
				array('after_save_post', array('Calendar_Post_Module', 'after_save_post'), array()),
			);
		else
			return array();
	}

	public function prepare_post()
	{
		Template_Layers::getInstance()->addAfter('make_event', 'postarea');
	}

	public function before_save_post($post_errors)
	{
		if (!isset($_REQUEST['deleteevent']) && Util::htmltrim($_POST['evtitle']) === '')
			$post_errors->addError('no_event');
	}

	public function after_save_post()
	{
		global $user_info, $modSettings;

		$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];

		$event = new Calendar_Event($_REQUEST['eventid'], $modSettings);

		try
		{
			$save_data = $event->validate($_POST);
		}
{'fraction_non_alphanumeric': 0.1468005018820577, 'fraction_numerical': 0.0035131744040150566, 'mean_word_length': 4.802037845705968, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4428731', 'n_tokens_mistral': 1317, 'n_tokens_neox': 1202, 'n_words': 324}