Revision 296 (by ahitrov, 2013/03/26 17:59:01) Promosite (anthill) project source
% unless ($errstr) {
Принято!
% } else {
<div  class="error"><% $errstr %></div>
<& "/comps/$prj/feedback_form.msn", ajax => 1, %ARGS &>
% }
<%args>

	$filled	=> undef

</%args>
<%init>

  my $prj = $request->{project};
  my $profile = $request->{project_profile};
  my $root = $request->{project_section};

  my $errstr;
  my ($document, $section);

  my $CP = 'UTF8';
  if ( $filled ) {
	$CP = 'ISO'		if Convert::Cyrillic::cstocs('ISO', 'UTF8', $filled) eq 'Отправить';
	$CP = 'KOI8'		if Convert::Cyrillic::cstocs('KOI8', 'UTF8', $filled) eq 'Отправить';
	$CP = 'WIN'		if Convert::Cyrillic::cstocs('WIN', 'UTF8', $filled) eq 'Отправить';

	my $emailto = $profile->mailto || 'ahitrov@mail.ru';
	$ARGS{name} = Convert::Cyrillic::cstocs($CP, 'UTF8', $ARGS{name});
	$ARGS{lastname} = Convert::Cyrillic::cstocs($CP, 'UTF8', $ARGS{lastname});
	$ARGS{job} = Convert::Cyrillic::cstocs($CP, 'UTF8', $ARGS{job});
	$ARGS{position} = Convert::Cyrillic::cstocs($CP, 'UTF8', $ARGS{position});
	$ARGS{question} = Convert::Cyrillic::cstocs($CP, 'UTF8', $ARGS{question});
	if ( $ARGS{doc_id} ) {
		$document = $keeper->get_document_by_id ( $ARGS{doc_id},
				class	=> 'promosuite::Article',
			);
	}
	if ( ref $document && $document->sections ) {
		($section) = $keeper->get_sections (
				id	=> $document->{sections},
				class	=> 'promosuite::SubSection',
				limit	=> 1,
				order_by	=> 'sorder',
			);
	}
	if ( $ARGS{email} =~ /([\w\.-]+)\@([a-zA-Z\.-]+)/ ) {
		my $msg = {
			to      => $emailto,
			from    => $ARGS{email},
			subject => 'RAMBLER 2 Developers - обратная связь на проекте',
			body    => $m->scomp ("/comps/$prj/feedback_template.msn", section => $section, doc => $document, %ARGS),
			};
		$m->comp('/subs/sendmail.msn', email => $msg)   if $msg->{body};
	} else {
		$errstr = 'Указан неверный e-mail';
	}
  }

</%init>