<?php /*

 ocPortal
 Copyright (c) ocProducts, 2004-2012

 See text/EN/licence.txt for full licencing information.


 NOTE TO PROGRAMMERS:
   Do not edit this file. If you need to make changes, save your changed file to the appropriate *_custom folder
   **** If you ignore this advice, then your website upgrades (e.g. for bug fixes) will likely kill your changes ****

*/

/**
 * @license		http://opensource.org/licenses/cpal_1.0 Common Public Attribution License
 * @copyright	ocProducts Ltd
 * @package		newsletter
 */

/**
 * Module page class.
 */
class Module_newsletter
{

	/**
	 * Standard modular info function.
	 *
	 * @return ?array	Map of module info (NULL: module is disabled).
	 */
	function info()
	{
		$info=array();
		$info['author']='Chris Graham';
		$info['organisation']='ocProducts';
		$info['hacked_by']=NULL;
		$info['hack_version']=NULL;
		$info['version']=9;
		$info['update_require_upgrade']=1;
		$info['locked']=false;
		return $info;
	}

	/**
	 * Standard modular uninstall function.
	 */
	function uninstall()
	{
		$GLOBALS['SITE_DB']->drop_if_exists('newsletter');
		$GLOBALS['SITE_DB']->drop_if_exists('newsletters');
		$GLOBALS['SITE_DB']->drop_if_exists('newsletter_archive');
		$GLOBALS['SITE_DB']->drop_if_exists('newsletter_subscribe');
		$GLOBALS['SITE_DB']->drop_if_exists('newsletter_drip_send');
		$GLOBALS['SITE_DB']->drop_if_exists('newsletter_periodic');

		delete_config_option('newsletter_text');
		delete_config_option('newsletter_title');
		delete_config_option('interest_levels');

		delete_value('newsletter_whatsnew');
		delete_value('newsletter_send_time');

		delete_specific_permission('change_newsletter_subscriptions');

		delete_menu_item_simple('_SEARCH:newsletter:type=misc');
	}

	/**
	 * Standard modular install function.
	 *
	 * @param  ?integer	What version we're upgrading from (NULL: new install)
	 * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
	 */
	function install($upgrade_from=NULL,$upgrade_from_hack=NULL)
	{
		if (is_null($upgrade_from))
		{
			$GLOBALS['SITE_DB']->create_table('newsletter',array(
				'id'=>'*AUTO',
				'email'=>'SHORT_TEXT',
				'join_time'=>'TIME',
				'code_confirm'=>'INTEGER',
				'the_password'=>'MD5',
				'pass_salt'=>'ID_TEXT',
				'language'=>'ID_TEXT',
				'n_forename'=>'SHORT_TEXT',
				'n_surname'=>'SHORT_TEXT',
			));
			$GLOBALS['SITE_DB']->create_index('newsletter','welcomemails',array('join_time'));
			$GLOBALS['SITE_DB']->create_index('newsletter','code_confirm',array('code_confirm'));

			$GLOBALS['SITE_DB']->create_table('newsletter_archive',array(
				'id'=>'*AUTO',
				'date_and_time'=>'INTEGER',
				'subject'=>'SHORT_TEXT',	// Comcode
				'newsletter'=>'LONG_TEXT',	// Comcode
				'language'=>'ID_TEXT',
				'importance_level'=>'INTEGER'
			));

			add_config_option('PAGE_TEXT','newsletter_text','transtext','return \'\';','FEATURE','NEWSLETTER');
			add_config_option('TITLE','newsletter_title','line','return get_option(\'site_name\').\' \'.ocp_mb_strtolower(do_lang(\'NEWSLETTER\'));','FEATURE','NEWSLETTER');

			add_specific_permission('NEWSLETTER','change_newsletter_subscriptions',false);

			require_lang('newsletter');
			//add_menu_item_simple('main_website',NULL,'NEWSLETTER','_SEARCH:newsletter:type=misc');
		}
		if ((!is_null($upgrade_from)) && ($upgrade_from<3))
		{
			$GLOBALS['SITE_DB']->add_table_field('newsletter','pass_salt','ID_TEXT','');
		}
		if ((!is_null($upgrade_from)) && ($upgrade_from<4))
		{
			$GLOBALS['SITE_DB']->add_table_field('newsletter','join_time','TIME');
		}
		if ((!is_null($upgrade_from)) && ($upgrade_from<5))
		{
			set_option('newsletter_text','[html]'.get_option('newsletter_text').'[/html]');
		}
		if ((is_null($upgrade_from)) || ($upgrade_from<6))
		{
			require_lang('newsletter');

			$GLOBALS['SITE_DB']->create_table('newsletters',array( // Would have been better named 'newsletter_subscribers' (but isn't for legacy reasons)
				'id'=>'*AUTO',
				'title'=>'SHORT_TRANS',
				'description'=>'LONG_TRANS',
			));

			$GLOBALS['SITE_DB']->query_insert('newsletters',array(
				'title'=>lang_code_to_default_content('GENERAL'),
				'description'=>lang_code_to_default_content('NEWSLETTER_GENERAL'),
			));

			$GLOBALS['SITE_DB']->create_table('newsletter_subscribe',array(
				'newsletter_id'=>'*AUTO_LINK',
				'the_level'=>'SHORT_INTEGER',
				'email'=>'*SHORT_TEXT',
			));
			$GLOBALS['SITE_DB']->create_index('newsletter_subscribe','peopletosendto',array('the_level'));
		}
		if ((!is_null($upgrade_from)) && ($upgrade_from<6)) // Ordering is important
		{
			$GLOBALS['SITE_DB']->alter_table_field('newsletter','email','SHORT_TEXT');
			$subscribes=$GLOBALS['SITE_DB']->query_select('newsletter',array('the_level','email'));
			foreach ($subscribes as $subscribe)
			{
				$subscribe['newsletter_id']=db_get_first_id();
				$GLOBALS['SITE_DB']->query_insert('newsletter_subscribe',$subscribe);
			}
			$GLOBALS['SITE_DB']->delete_table_field('newsletter','the_level');
		}
		if ((is_null($upgrade_from)) || ($upgrade_from<7))
		{
			add_config_option('USE_INTEREST_LEVELS','interest_levels','tick','return \'0\';','FEATURE','NEWSLETTER');
		}
		if ((!is_null($upgrade_from)) && ($upgrade_from<7))
		{
			// THIS STUFF DONE BECAUSE WE NEED A NUMERIC ID FOR IMPORT/EXPORT OF NEWSLETTER SUBSCRIBERS
			/*$GLOBALS['SITE_DB']->add_table_field('newsletter','id','INTEGER'); // can't handle more than one row when it tries to become a key, as not sequential
			$GLOBALS['SITE_DB']->change_primary_key('newsletter',array('id'));
			$GLOBALS['SITE_DB']->alter_table_field('newsletter','id','AUTO');*/
			// Works with mySQL only, but it's okay because before v4 of ocPortal (which this upgrades to), there's only mySQL support
			$GLOBALS['SITE_DB']->query('ALTER TABLE '.get_table_prefix().'newsletter DROP PRIMARY KEY');
			$GLOBALS['SITE_DB']->query('ALTER TABLE '.get_table_prefix().'newsletter ADD id INT NOT NULL AUTO_INCREMENT PRIMARY KEY');
			$GLOBALS['SITE_DB']->query_insert('db_meta',array('m_table'=>'newsletter','m_name'=>'id','m_type'=>'AUTO*'));

			// Add some extra data...
			$GLOBALS['SITE_DB']->add_table_field('newsletter','n_forename','SHORT_TEXT');
			$GLOBALS['SITE_DB']->add_table_field('newsletter','n_surname','SHORT_TEXT');
		}
		if ((is_null($upgrade_from)) || ($upgrade_from<8))
		{
			$GLOBALS['SITE_DB']->create_table('newsletter_drip_send',array(
				'id'=>'*AUTO',
				'd_inject_time'=>'TIME',
				'd_subject'=>'SHORT_TEXT',
				'd_message'=>'LONG_TEXT',
				'd_html_only'=>'BINARY',
				'd_to_email'=>'SHORT_TEXT',
				'd_to_name'=>'SHORT_TEXT',
				'd_from_email'=>'SHORT_TEXT',
				'd_from_name'=>'SHORT_TEXT',
				'd_priority'=>'SHORT_INTEGER',
				'd_template'=>'ID_TEXT',
			));
			$GLOBALS['SITE_DB']->create_index('newsletter_drip_send','d_inject_time',array('d_inject_time'));
		}
		if ((is_null($upgrade_from)) || ($upgrade_from<9))
		{
			$GLOBALS['SITE_DB']->create_table('newsletter_periodic',array(
				'id'=>'*AUTO',
				'np_message'=>'LONG_TEXT',
				'np_subject'=>'LONG_TEXT',
				'np_lang'=>'LANGUAGE_NAME',
				'np_send_details'=>'LONG_TEXT',
				'np_html_only'=>'BINARY',
				'np_from_email'=>'SHORT_TEXT',
				'np_from_name'=>'SHORT_TEXT',
				'np_priority'=>'SHORT_INTEGER',
				'np_csv_data'=>'LONG_TEXT',
				'np_frequency'=>'SHORT_TEXT',
				'np_day'=>'SHORT_INTEGER',
				'np_in_full'=>'BINARY',
				'np_template'=>'ID_TEXT',
				'np_last_sent'=>'TIME',
			));
		}
		if ((!is_null($upgrade_from)) && ($upgrade_from>=8) && ($upgrade_from<9))
		{
			$GLOBALS['SITE_DB']->add_table_field('newsletter_drip_send','d_template','ID_TEXT');
		}
	}

	/**
	 * Standard modular entry-point finder function.
	 *
	 * @return ?array	A map of entry points (type-code=>language-code) (NULL: disabled).
	 */
	function get_entry_points()
	{
		return ($GLOBALS['SITE_DB']->query_value('newsletters','COUNT(*)')==0)?array():array('misc'=>'NEWSLETTER_JOIN');
	}

	/**
	 * Standard modular run function.
	 *
	 * @return tempcode	The result of execution.
	 */
	function run()
	{
		require_lang('newsletter');

		$type=get_param('type','misc');

		if ($type=='confirm') return $this->newsletter_confirm_joining();
		if ($type=='do') return $this->newsletter_maintenance();
		if ($type=='reset') return $this->newsletter_password_reset();
		if ($type=='unsub') return $this->newsletter_unsubscribe();
		if ($type=='misc') return $this->newsletter_form();

		return new ocp_tempcode();
	}

	/**
	 * The UI to sign up to the newsletter (actually, generally manage subscription).
	 *
	 * @return tempcode		The UI
	 */
	function newsletter_form()
	{
		$title=get_screen_title('_NEWSLETTER_JOIN',true,array(get_option('newsletter_title')));

		$newsletters=$GLOBALS['SITE_DB']->query_select('newsletters',array('*'));
		if (count($newsletters)==0) inform_exit(do_lang_tempcode('NO_CATEGORIES'));

		$post_url=build_url(array('page'=>'_SELF','type'=>'do'),'_SELF');
		$submit_name=do_lang_tempcode('NEWSLETTER_JOIN');

		if (!is_guest()) $their_email=get_param('email',$GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member())); else $their_email=get_param('email','');
		$forename='';
		$surname='';

		$message=get_option('newsletter_text');
		if (has_actual_page_access(get_member(),'admin_config'))
		{
			if ($message!='') $message.=' [semihtml]<span class="associated_link"><a href="{$PAGE_LINK*,_SEARCH:admin_config:category:FEATURE#group_NEWSLETTER}">'.do_lang('EDIT').'</a></span>[/semihtml]';
		}
		$text=comcode_to_tempcode($message,NULL,true);

		// Build up the join form
		$fields=new ocp_tempcode();
		require_code('form_templates');
		$fields->attach(form_input_line(do_lang_tempcode('EMAIL_ADDRESS'),do_lang_tempcode('DESCRIPTION_SUBSCRIBE_ADDRESS'),'email',$their_email,true));
		$fields->attach(form_input_line(do_lang_tempcode('FORENAME'),'','forename',$forename,false));
		$fields->attach(form_input_line(do_lang_tempcode('SURNAME'),'','surname',$surname,false));
		$fields->attach(form_input_password(do_lang_tempcode('YOUR_PASSWORD'),do_lang_tempcode('DESCRIPTION_MAINTENANCE_PASSWORD'),'password',false));
		$fields->attach(form_input_password(do_lang_tempcode('CONFIRM_PASSWORD'),'','password_confirm',false));
		if (count(find_all_langs())!=1)
			$fields->attach(form_input_list(do_lang_tempcode('LANGUAGE'),'','lang',nice_get_langs(user_lang())));
		$level=get_param_integer('level',NULL);
		if (is_null($level))
		{
			$level=3;
		}
		$l=form_input_list_entry('0',false,do_lang_tempcode('NEWSLETTER_0'));
		$l->attach(form_input_list_entry('1',$level==1,do_lang_tempcode('NEWSLETTER_1')));
		$l->attach(form_input_list_entry('2',$level==2,do_lang_tempcode('NEWSLETTER_2')));
		$l->attach(form_input_list_entry('3',$level==3,do_lang_tempcode('NEWSLETTER_3')));
		$l->attach(form_input_list_entry('4',$level==4,do_lang_tempcode('NEWSLETTER_4')));
		$fields->attach(do_template('FORM_SCREEN_FIELD_SPACER',array('TITLE'=>do_lang_tempcode('NEWSLETTER_SUBSCRIPTIONS'))));
		foreach ($newsletters as $newsletter)
		{
			$newsletter_title=get_translated_text($newsletter['title']);
			$newsletter_description=get_translated_text($newsletter['description']);
			if (get_option('interest_levels')=='1')
			{
				$fields->attach(form_input_list(do_lang_tempcode('SUBSCRIPTION_LEVEL_FOR',make_string_tempcode(escape_html($newsletter_title))),do_lang_tempcode('DESCRIPTION_SUBSCRIPTION_LEVEL',escape_html($newsletter_description)),'level'.strval($newsletter['id']),$l));
			} else
			{
				$fields->attach(form_input_tick(do_lang_tempcode('SUBSCRIBE_TO',make_string_tempcode(escape_html($newsletter_title))),make_string_tempcode(escape_html($newsletter_description)),'level'.strval($newsletter['id']),$level!=0));
			}
		}

		$text->attach(paragraph(do_lang_tempcode('CHANGE_SETTINGS_BY_RESUBSCRIBING')));

		$javascript="
			var form=document.getElementById('password').form;
			form.old_submit=form.onsubmit;
			form.onsubmit=function()
				{
					if ((form.elements['password_confirm']) && (form.elements['password_confirm'].value!=form.elements['password'].value))
					{
						window.fauxmodal_alert('".php_addslashes(do_lang('PASSWORD_MISMATCH'))."');
						return false;
					}
					if (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();
					return true;
				};
		";

		return do_template('FORM_SCREEN',array('_GUID'=>'24d7575465152f450c5a8e62650bf6c8','JAVASCRIPT'=>$javascript,'HIDDEN'=>'','FIELDS'=>$fields,'SUBMIT_NAME'=>$submit_name,'URL'=>$post_url,'TITLE'=>$title,'TEXT'=>$text));
	}

	/**
	 * The actualiser for newsletter subscription maintenance (adding, updating, deleting).
	 *
	 * @return tempcode		The UI
	 */
	function newsletter_maintenance()
	{
		require_code('type_validation');

		breadcrumb_set_parents(array(array('_SELF:_SELF:misc',get_option('newsletter_title'))));

		$title=get_screen_title('_NEWSLETTER_JOIN',true,array(get_option('newsletter_title')));

		// Add
		$email=trim(post_param('email'));
		$password=trim(post_param('password',''));
		$forename=trim(post_param('forename'));
		$surname=trim(post_param('surname'));
		if ($password!=trim(post_param('password_confirm','')))
			warn_exit(make_string_tempcode(escape_html(do_lang('PASSWORD_MISMATCH'))));
		$lang=post_param('lang',user_lang());
		if (!is_valid_email_address($email))
		{
			return warn_screen($title,do_lang_tempcode('IMPROPERLY_FILLED_IN'));
		}

		$message=do_lang_tempcode('NEWSLETTER_UPDATE');
		$old_confirm=$GLOBALS['SITE_DB']->query_value_null_ok('newsletter','code_confirm',array('email'=>$email));

		// New (or as new - replace old unconfirmed records)
		if ((is_null($old_confirm)) || ($old_confirm!=0))
		{
			// As it is new we need to actually confirm you were setting some subscription settings
			$newsletters=$GLOBALS['SITE_DB']->query_select('newsletters',array('id'));
			$found_level=false;
			foreach ($newsletters as $newsletter)
			{
				if (get_option('interest_levels')=='1')
				{
					$level=post_param_integer('level'.strval($newsletter['id']));
				} else
				{
					$level=post_param_integer('level'.strval($newsletter['id']),0);
					if ($level==1) $level=4;
				}
				if ($level!=0) $found_level=true;
			}
			if (!$found_level)
			{
				// No subscription settings
				warn_exit(do_lang_tempcode('NOT_NEWSLETTER_SUBSCRIBER'));
			}

			$code_confirm=is_null($old_confirm)?mt_rand(1,32000):$old_confirm;
			if ($password=='') $password=get_rand_password();
			$salt=produce_salt();
			if (is_null($old_confirm))
			{
				$GLOBALS['SITE_DB']->query_insert('newsletter',array('n_forename'=>$forename,'n_surname'=>$surname,'join_time'=>time(),'language'=>$lang,'email'=>$email,'code_confirm'=>$code_confirm,'pass_salt'=>$salt,'the_password'=>md5($password.$salt)));
				$this->_send_confirmation($email,$code_confirm,$password,$forename,$surname);
			} else
			{
				$GLOBALS['SITE_DB']->query_update('newsletter',array('n_forename'=>$forename,'n_surname'=>$surname,'join_time'=>time(),'language'=>$lang),array('email'=>$email),'',1);
				$this->_send_confirmation($email,$code_confirm,NULL,$forename,$surname);
			}
			$message=do_lang_tempcode('NEWSLETTER_CONFIRM',escape_html($email));
		}

		// Existing, OR it is new and we are just proceeding to save the subscription settings...

		// Change/make settings
		$old_password=$GLOBALS['SITE_DB']->query_value('newsletter','the_password',array('email'=>$email));
		$old_salt=$GLOBALS['SITE_DB']->query_value('newsletter','pass_salt',array('email'=>$email));
		if ((!has_specific_permission(get_member(),'change_newsletter_subscriptions')) && (!is_null($old_confirm)) && ($old_confirm==0) && ($old_password!='') && ($old_password!=md5($password.$old_salt))) // Access denied. People who can change any subscriptions can't get denied.
		{
			// Access denied to an existing record that was confirmed
			$_reset_url=build_url(array('page'=>'_SELF','type'=>'reset','email'=>$email),'_SELF');
			$reset_url=$_reset_url->evaluate();
			return warn_screen($title,do_lang_tempcode('NEWSLETTER_PASSWORD_RESET',escape_html($reset_url)));
		} else
		{
			// Access granted, make edit
			$newsletters=$GLOBALS['SITE_DB']->query_select('newsletters',array('id'));
			foreach ($newsletters as $newsletter)
			{
				if (get_option('interest_levels')=='1')
				{
					$level=post_param_integer('level'.strval($newsletter['id']));
				} else
				{
					$level=post_param_integer('level'.strval($newsletter['id']),0);
					if ($level==1) $level=4;
				}
				// First we delete
				$GLOBALS['SITE_DB']->query_delete('newsletter_subscribe',array('newsletter_id'=>$newsletter['id'],'email'=>$email),'',1);
				if ($level!=0) // Then we put back if it's not a 0 level
				{
					$GLOBALS['SITE_DB']->query_insert('newsletter_subscribe',array('newsletter_id'=>$newsletter['id'],'email'=>$email,'the_level'=>$level));
				}
			}

			// Update name etc if it's an edit
			if ((!is_null($old_confirm)) && ($old_confirm==0))
			{
				$GLOBALS['SITE_DB']->query_update('newsletter',array('n_forename'=>$forename,'n_surname'=>$surname),array('email'=>$email),'',1);
			}
		}

		// Done, show result
		return inform_screen($title,$message);
	}

	/**
	 * The actualiser for resetting newsletter password.
	 *
	 * @return tempcode		The UI
	 */
	function newsletter_password_reset()
	{
		$title=get_screen_title(get_option('newsletter_title'),false);

		$email=trim(get_param('email'));
		$lang=$GLOBALS['SITE_DB']->query_value('newsletter','language',array('email'=>$email));
		$salt=$GLOBALS['SITE_DB']->query_value('newsletter','pass_salt',array('email'=>$email));
		$new_password=get_rand_password();
		$GLOBALS['SITE_DB']->query_update('newsletter',array('the_password'=>md5($new_password.$salt)),array('email'=>$email),'',1);

		$message=do_lang('NEWSLETTER_PASSWORD_CHANGE',comcode_escape(get_ip_address()),comcode_escape($new_password),NULL,$lang);

		require_code('mail');
		mail_wrap(get_option('newsletter_title'),$message,array($email),$GLOBALS['FORUM_DRIVER']->get_username(get_member()));

		breadcrumb_set_self(do_lang_tempcode('NEWSLETTER_PASSWORD_BEEN_RESET'));
		breadcrumb_set_parents(array(array('_SELF:_SELF:misc',get_option('newsletter_title'))));

		return inform_screen($title,protect_from_escaping(do_lang('NEWSLETTER_PASSWORD_BEEN_RESET',NULL,NULL,NULL,$lang)));
	}

	/**
	 * The actualiser for unsubscribing from the newsletter.
	 *
	 * @return tempcode		The UI
	 */
	function newsletter_unsubscribe()
	{
		$id=get_param_integer('id');
		$hash=get_param('hash');

		$_subscriber=$GLOBALS['SITE_DB']->query_select('newsletter',array('*'),array('id'=>$id),'',1);
		if (!array_key_exists(0,$_subscriber)) fatal_exit(do_lang_tempcode('INTERNAL_ERROR'));
		$subscriber=$_subscriber[0];

		$needed_hash=best_hash($subscriber['the_password'],'xunsub');

		if ($hash!=$needed_hash)
		{
			warn_exit(do_lang_tempcode('COULD_NOT_UNSUBSCRIBE'));
		}

		$title=get_screen_title('NEWSLETTER_UNSUBSCRIBED');

		$GLOBALS['SITE_DB']->query_delete('newsletter_subscribe',array('email'=>$subscriber['email']));

		return inform_screen($title,do_lang_tempcode('FULL_NEWSLETTER_UNSUBSCRIBED',escape_html(get_site_name())));
	}

	/**
	 * Send a newsletter join confirmation.
	 *
	 * @param  SHORT_TEXT		The e-mail address
	 * @param  SHORT_TEXT		The confirmation code
	 * @param  ?SHORT_TEXT		The newsletter password (NULL: password may not be viewed, because it's been permanently hashed already)
	 * @param  string				Subscribers forename
	 * @param  string				Subscribers surname
	 */
	function _send_confirmation($email,$code_confirm,$password,$forename,$surname)
	{
		if (is_null($password)) $password=do_lang('NEWSLETTER_PASSWORD_ENCRYPTED');

		$_url=build_url(array('page'=>'newsletter','type'=>'confirm','email'=>$email,'confirm'=>$code_confirm),'_SELF',NULL,false,true);
		$url=$_url->evaluate();
		$message=do_lang('NEWSLETTER_SIGNUP_TEXT',comcode_escape($url),comcode_escape($password),array($forename,$surname,$email,get_site_name()));

		require_code('mail');
		mail_wrap(do_lang('NEWSLETTER_SIGNUP'),$message,array($email),$GLOBALS['FORUM_DRIVER']->get_username(get_member()));
	}

	/**
	 * The UI for having confirmed an e-mail address onto the newsletter.
	 *
	 * @return tempcode		The UI
	 */
	function newsletter_confirm_joining()
	{
		$title=get_screen_title(get_option('newsletter_title'),false);

		breadcrumb_set_parents(array(array('_SELF:_SELF:misc',get_option('newsletter_title'))));

		$code_confirm=get_param_integer('confirm');
		$email=trim(get_param('email'));
		$correct_confirm=$GLOBALS['SITE_DB']->query_value('newsletter','code_confirm',array('email'=>$email));
		if ($correct_confirm==$code_confirm)
		{
			$GLOBALS['SITE_DB']->query_update('newsletter',array('code_confirm'=>0),array('email'=>$email),'',1);
			return inform_screen($title,do_lang_tempcode('NEWSLETTER_CONFIRMED'));
		}

		return warn_screen($title,do_lang_tempcode(($correct_confirm==0)?'ALREADY_CONFIRMED':'INCORRECT_CONFIRMATION'));
	}

}


