Skip to content
This repository has been archived by the owner on Oct 26, 2020. It is now read-only.

Commit

Permalink
v1
Browse files Browse the repository at this point in the history
  • Loading branch information
benmag committed Dec 7, 2016
0 parents commit c3d7757
Show file tree
Hide file tree
Showing 23 changed files with 1,803 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .idea/copyright/QUT_CC.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/humhub-modules-email_whitelist.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

212 changes: 212 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 77 additions & 0 deletions EmailWhitelistEvents.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

/**
* Connected Communities Initiative
* Copyright (C) 2016 Queensland University of Technology
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

class EmailWhitelistEvents{

/**
* Defines what to do if admin menu is initialized.
*
* @param type $event
*/
public static function onAdminMenuInit($event)
{
$event->sender->addItem(array(
'label' => Yii::t('EmailWhitelistModule.base', 'Email Whitelist'),
'url' => Yii::app()->createUrl('//email_whitelist/admin'),
'group' => 'manage',
'icon' => '<i class="fa fa-check-square-o"></i>',
'isActive' => (Yii::app()->controller->module && Yii::app()->controller->module->id == 'email_whitelist' && Yii::app()->controller->id == 'admin'),
'sortOrder' => 550,
));
}

public static function onUniqueEMailValidator($event)
{

$model = new AccountRegisterForm;
$allowed = EmailWhitelist::toArray();

if (isset($_POST['AccountRegisterForm'])) {
$model->attributes = $_POST['AccountRegisterForm'];

if ($model->validate()) {

// Make sure the address is valid
if (filter_var($model->email, FILTER_VALIDATE_EMAIL)) {
$domain = strtolower(array_pop(@explode('@', $model->email)));
if (! in_array($domain, $allowed)) { // email not whitelisted

// empty $_POST['AccountRegisterForm'] so it doesn't submit anything
$_POST['AccountRegisterForm'] = null;

Yii::app()->request->redirect(Yii::app()->createUrl('//email_whitelist/denied', array()));
// TODO
// Redirect them to an error page



// render the invalid email domain notification
// Yii::app()->getController()->widget('application.modules.email_whitelist.widgets.InvalidEmailDomain', array());
// Yii::app()->getController()->widget('application.modules.email_whitelist.widgets.InvalidEmailDomain', array(), true); -->
}
}

}

}

}

}
35 changes: 35 additions & 0 deletions EmailWhitelistModule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/**
* Connected Communities Initiative
* Copyright (C) 2016 Queensland University of Technology
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

class EmailWhiteListModule extends HWebModule{

/**
* Inits the Module
*/
public function init()
{

$this->setImport(array(
'email_whitelist.models.*',
));

}

}
Loading

0 comments on commit c3d7757

Please sign in to comment.