Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
MailsendingController.php
1 <?php
2 /**
3  *
4  */
6 {
7  public $layout = true;
8  public $mailLayout = false;
9 
10  public function actionIndex()
11  {
12  $form = new MailsendingForm();
13  if (isset($_GET['link']) && is_string($_GET['link'])) {
14  $form->link = $_GET['link'];
15  } else {
16  throw new CHttpException(400, 'Empty link');
17  }
18 
19  if (isset($_POST['MailsendingForm'])) {
20  $form->attributes = $_POST['MailsendingForm'];
21  if ($form->validate()) {
22  $this->mailLayout = '//layouts/mail';
23  $subject = SocialModule::t('Link was sent to you');
24  $message = $this->renderMail('/mail_templates/mailsending', $subject, array('model' => $form), true);
25  $notification = new Notification(
26  $subject,
27  $message,
28  array(new EmailRecipient($form->friends_email, Yii::app()->getModule('social')->mailsendingEmail , '', true))
29  );
30  Yii::app()->notificationManager->notifyAbout($notification);
31  Yii::app()->user->setFlash('social-mailing', SocialModule::t('Your link was sent!'));
32  $form = new MailsendingForm();
33  }
34  }
35 
36  $this->renderPartial('index', array('model' => $form));
37  }
38 
39 }