/**
  * Returns a list of whitelisted domains
  */
 public function toArray()
 {
     $whitelist = array();
     foreach (EmailWhitelist::find()->all() as $row) {
         $whitelist[] = strtolower($row['domain']);
     }
     return $whitelist;
 }
 public function search($params)
 {
     $query = EmailWhitelist::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     // load the search form data and validate
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     // adjust the query by adding the filters
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['domain' => $this->domain]);
     return $dataProvider;
 }
 /**
  * Check to see that the email address provided
  * is on the white list.
  *
  * @param $event
  * @return mixed
  */
 public function onUniqueEMailValidator($event)
 {
     $canRegister = \humhub\models\Setting::Get('anonymousRegistration', 'authentication_internal');
     $registerModel = new \humhub\modules\user\models\forms\AccountRegister();
     if ($canRegister) {
         if ($registerModel->load(Yii::$app->request->post())) {
             if (!EmailWhitelist::emailIsAllowed($registerModel->email)) {
                 $event->isValid = false;
                 return Yii::$app->getResponse()->redirect(Url::to(['/email_whitelist/denied/index']));
             }
         }
     }
 }
 /**
  * Deletes a whitelist record
  */
 public function actionDelete()
 {
     $id = (int) Yii::$app->request->get('id');
     $doit = (int) Yii::$app->request->get('doit');
     $emailWhitelist = EmailWhitelist::findOne(['id' => $id]);
     if ($emailWhitelist == null) {
         throw new \yii\web\HttpException(404, "EmailWhitelist record not found!");
     }
     if ($doit == 2) {
         $this->forcePostRequest();
         $emailWhitelist->delete();
         return $this->redirect(Url::toRoute('index'));
     }
     return $this->render('delete', array('model' => $emailWhitelist));
 }