Example #1
0
 /**
  * Sends an email to the specified email address using the information collected by this model.
  *
  * @param  string  $email the target email address
  * @return boolean whether the email was sent
  */
 public function sendEmail()
 {
     $model = new ContactMsg();
     $subject = Yii::t("app/contact", "Message from {site}", ['dot' => false, 'name' => $this->name, 'email' => $this->email, 'body' => $this->body, 'phone' => $this->phone, 'site' => Yii::$app->name]);
     $body = Yii::t("app/contact", "Contact message<br/>Name: {name}<br/>Email: {email}<br/>Phone: {phone}<br/>Message: {body}", ['dot' => false, 'name' => $this->name, 'email' => $this->email, 'body' => $this->body, 'phone' => $this->phone]);
     if ($model) {
         $model->from_email = $this->email;
         $model->subject = $subject;
         $model->text = $body;
         $model->save(false);
     }
     $valid = EmailConfig::eachEmail(function ($email) use($subject, $body) {
         return Yii::$app->mailer->compose()->setTo($email)->setFrom(Yii::$app->params['adminEmailName'])->setReplyTo($this->email)->setSubject($subject)->setHtmlBody($body)->send();
     });
     if ($valid === false) {
         return false;
     }
     return true;
 }
Example #2
0
<?php

if (YII_ENV_DEV) {
    $params = \yii\helpers\ArrayHelper::merge(require __DIR__ . '/params.php', require __DIR__ . '/params-local.php');
    $db = \yii\helpers\ArrayHelper::merge(require __DIR__ . '/db.php', require __DIR__ . '/db-local.php');
} else {
    $params = (require __DIR__ . '/params.php');
    $db = (require __DIR__ . '/db.php');
}
require __DIR__ . '/aliases.php';
Yii::$container->set('yii\\validators\\NumberValidator', ['class' => 'app\\base\\validators\\NumberValidator']);
$config = ['name' => 'My Application', 'id' => 'adm-app', 'timeZone' => 'Europe/Riga', 'basePath' => dirname(__DIR__), 'layout' => '/main', 'bootstrap' => ['log', 'debug', 'urlManager', 'i18n', 'gii'], 'on beforeRequest' => function ($event) {
    $params = \pavlinter\admparams\models\Params::bootstrap();
    Yii::$app->params = \yii\helpers\ArrayHelper::merge(Yii::$app->params, $params);
    \pavlinter\admeconfig\models\EmailConfig::changeMailConfig();
}, 'modules' => ['debug' => ['class' => 'yii\\debug\\Module', 'allowedIPs' => ['127.0.0.1', '::1']], 'gii' => ['class' => 'app\\modules\\admgii\\Module', 'allowedIPs' => ['127.0.0.1', '::1']], 'adm' => ['class' => 'pavlinter\\adm\\Adm', 'modules' => ['appadm', 'admpages', 'admunderconst', 'admgoogletools', 'admlivechat', 'admparams', 'admeconfig', 'admhidemenu'], 'components' => ['manager' => ['userClass' => 'app\\models\\User', 'userSearchClass' => 'app\\core\\adm\\models\\UserSearch', 'loginFormClass' => 'app\\core\\adm\\models\\LoginForm', 'authItemClass' => 'app\\core\\adm\\models\\AuthItem', 'authItemSearchClass' => 'app\\core\\adm\\models\\AuthItemSearch', 'authRuleClass' => 'app\\core\\adm\\models\\AuthRule', 'authRuleSearchClass' => 'app\\core\\adm\\models\\AuthRuleSearch', 'authItemChildClass' => 'app\\core\\adm\\models\\AuthItemChild', 'authItemChildSearchClass' => 'app\\core\\adm\\models\\AuthItemChildSearch', 'authAssignmentClass' => 'app\\core\\adm\\models\\AuthAssignment', 'authAssignmentSearchClass' => 'app\\core\\adm\\models\\AuthAssignmentSearch', 'languageClass' => 'app\\core\\adm\\models\\Language', 'languageSearchClass' => 'app\\core\\adm\\models\\LanguageSearch', 'sourceMessageClass' => 'app\\core\\adm\\models\\SourceMessage', 'sourceMessageSearchClass' => 'app\\core\\adm\\models\\SourceMessageSearch', 'messageClass' => 'app\\core\\adm\\models\\Message']], 'controllerMap' => ['user' => ['class' => 'app\\core\\adm\\controllers\\UserController'], 'elfinder' => require __DIR__ . '/elfinder.php']], 'profilelogin' => ['class' => 'app\\modules\\profilelogin\\Module'], 'appadm' => ['class' => 'app\\modules\\appadm\\Module'], 'admgoogletools' => ['class' => 'app\\modules\\admgoogletools\\Module'], 'admlivechat' => ['class' => 'app\\modules\\admlivechat\\Module'], 'admunderconst' => ['class' => 'app\\modules\\admunderconst\\Module'], 'admhidemenu' => ['class' => 'app\\modules\\admhidemenu\\Module'], 'cloud' => ['class' => 'app\\modules\\cloud\\Cloud'], 'gridview' => ['class' => '\\kartik\\grid\\Module'], 'admpages' => ['class' => 'pavlinter\\admpages2\\Module', 'pageLayouts' => function ($m) {
    return ['main' => $m::t('layouts', 'Main Page', ['dot' => false]), 'contact' => $m::t('layouts', 'Contact', ['dot' => false])];
}, 'pageRedirect' => ['contact' => ['pages/contact']], 'pageTypes' => function ($m) {
    return [];
}, 'pageLayout' => '/main', 'closeDeletePage' => [1, 2, 3], 'files' => ['page' => ['dirs' => ['@webroot/files/data/pages/{id}/gallery'], 'startPath' => 'data::pages::{id}'], 'main' => ['dirs' => ['@webroot/files/data/pages/{id}/gallery'], 'startPath' => 'data::pages::{id}']], 'components' => ['manager' => ['pageSearchClass' => 'app\\core\\admpages\\models\\PageSearch']]], 'admparams' => ['class' => 'pavlinter\\admparams\\Module'], 'admeconfig' => ['class' => 'pavlinter\\admeconfig\\Module'], 'display2' => ['class' => 'pavlinter\\display2\\Module', 'categories' => ['pages' => ['imagesWebDir' => '@web/files/data/pages', 'imagesDir' => '@webroot/files/data/pages', 'defaultWebDir' => '@web/files/default', 'defaultDir' => '@webroot/files/default', 'mode' => \pavlinter\display2\objects\Image::MODE_OUTBOUND]]]], 'components' => ['ar' => ['class' => 'app\\modules\\activeResponse\\components\\ActiveResponse'], 'user' => ['class' => 'app\\components\\User', 'identityClass' => 'app\\models\\User', 'enableAutoLogin' => true], 'authManager' => ['class' => 'app\\components\\DbManager'], 'mobileDetect' => ['class' => 'app\\components\\MobileDetect'], 'shortcode' => ['class' => 'app\\components\\Shortcode', 'callbacks' => require __DIR__ . '/shortcodes.php'], 'urlManager' => ['class' => 'app\\components\\UrlManager', 'rules' => ['' => 'admpages/default/main', 'page/<alias:([A-Za-z0-9_-])+>' => 'admpages/default/index']], 'i18n' => ['class' => 'app\\components\\I18N', 'access' => function () {
    return !Yii::$app->user->isGuest && Yii::$app->user->can('Adm-Transl');
}, 'dialog' => 'mp', 'router' => '/adm/source-message/dot-translation', 'categoryUrl' => '@web/{lang}/adm/source-message/index?SourceMessageSearch[category]={category}', 'translations' => ['app*' => ['class' => 'app\\components\\DbMessageSource', 'forceTranslation' => true, 'dotMode' => true], 'model*' => ['class' => 'pavlinter\\translation\\DbMessageSource', 'forceTranslation' => true, 'dotMode' => false], 'adm*' => ['class' => 'pavlinter\\translation\\DbMessageSource', 'forceTranslation' => true, 'dotMode' => true], 'modelAdm*' => ['class' => 'pavlinter\\translation\\DbMessageSource', 'forceTranslation' => true, 'dotMode' => false]]], 'assetManager' => ['class' => 'app\\components\\AssetManager', 'appendTimestamp' => true, 'bundles' => ['yii\\bootstrap\\BootstrapAsset' => ['class' => 'app\\assets_b\\BootstrapAsset'], 'yii\\bootstrap\\BootstrapThemeAsset' => ['class' => 'app\\assets_b\\BootstrapThemeAsset']]], 'view' => ['class' => 'app\\components\\View', 'title' => 'My title', 'theme' => ['pathMap' => ['@vendor/pavlinter/yii2-adm-pages2/admpages2/views' => '@app/views/admpages', '@vendor/pavlinter/yii2-adm/adm/views' => '@app/core/adm/views', '@vendor/mihaildev/yii2-elfinder/views' => '@app/core/elfinder/views']]], 'request' => ['class' => 'app\\components\\Request', 'cookieValidationKey' => 'FONQ3Oh7wxcvVI1ioWvnZ6gJzwjyBV6xU'], 'response' => ['class' => 'app\\components\\Response'], 'formatter' => ['class' => 'app\\components\\Formatter', 'datetimeFormat' => 'dd.MM.yyyy HH:mm:ss', 'dateFormat' => 'dd.MM.yyyy', 'decimalSeparator' => ',', 'thousandSeparator' => ' ', 'currencyCode' => 'EUR', 'numberFormatterOptions' => [7 => 0, 6 => 2]], 'display' => ['class' => 'app\\components\\Display'], 'cache' => ['class' => 'app\\components\\FileCache'], 'errorHandler' => ['class' => 'app\\components\\ErrorHandler', 'errorAction' => 'site/error'], 'mailer' => ['class' => 'app\\components\\Mailer', 'viewPath' => '@app/mail'], 'security' => ['class' => 'app\\components\\Security'], 'session' => ['class' => 'app\\components\\Session'], 'log' => ['class' => 'app\\components\\Dispatcher', 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'db' => $db], 'params' => $params];
return $config;