Revision 296 (by ahitrov, 2013/03/26 17:59:01) Promosite (anthill) project source
<%args>

	$CP	=> undef

</%args>
<%init>

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

  my $emailto = $profile->mailto || 'ahitrov@mail.ru';

  return 'Вы не указали имя'		unless $ARGS{name};
  $ARGS{name} = Convert::Cyrillic::cstocs($CP, 'UTF8', $ARGS{name});

  return 'Вы не указали фамилию'	unless $ARGS{lastname};
  $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});

  return 'Вы не заполнили адрес электронной почты'	unless $ARGS{email};

  return 'Вы не заполнили поле вопроса'	unless $ARGS{question};
  $ARGS{question} = Convert::Cyrillic::cstocs($CP, 'UTF8', $ARGS{question});

  return 'Вы не заполнили поле вопроса'	unless $ARGS{question};

  my ($document, $section);
  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 {
	return 'Указан неверный e-mail';
  }

  return undef;

</%init>