コード例 #1
0
ファイル: Subscribe.php プロジェクト: pers1307/yii
 public function notification($event)
 {
     $model = User::find()->where(['roles' => 'admin'])->all();
     foreach ($model as $r) {
         Common::sendMail();
     }
 }
コード例 #2
0
ファイル: MainController.php プロジェクト: pers1307/yii
 public function actionViewAdvert($id)
 {
     $model = Advert::findOne($id);
     $data = ['name', 'email', 'text'];
     $model_feedback = new DynamicModel($data);
     $model_feedback->addRule('name', 'required');
     $model_feedback->addRule('email', 'required');
     $model_feedback->addRule('text', 'required');
     $model_feedback->addRule('email', 'email');
     if (\Yii::$app->request->isPost) {
         if ($model_feedback->load(\Yii::$app->request->post()) && $model_feedback->validate()) {
             \Yii::$app->common->sendMail('Subject Advert', $model_feedback->text);
         }
     }
     $user = $model->user;
     $images = Common::getImageAdvert($model, false);
     $current_user = ['email' => '', 'username' => ''];
     if (!\Yii::$app->user->isGuest) {
         $current_user['email'] = \Yii::$app->user->identity->email;
         $current_user['username'] = \Yii::$app->user->identity->username;
     }
     return $this->render('view_advert', ['model' => $model, 'model_feedback' => $model_feedback, 'user' => $user, 'images' => $images, 'current_user' => $current_user]);
 }
コード例 #3
0
 public function actionEvent()
 {
     $component = new Common();
     $component->on(Common::EVENT_NOTIFY, [$component, 'notifyAdmin']);
     $component->sendMail("*****@*****.**", "Test", "text text");
 }