parent
6d80ec6f85
commit
9af6dd0bc6
@ -0,0 +1,34 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Application\Migrations\Schema\V111; |
||||
|
||||
use Application\Migrations\AbstractMigrationChamilo; |
||||
use Doctrine\DBAL\Schema\Schema; |
||||
|
||||
/** |
||||
* Class Version20171002154600 |
||||
* |
||||
* Added a new option in registration settings called "confirmation" |
||||
* This option prevents the new user to login in the platform if your account is not |
||||
* confirmed via email. |
||||
* @package Application\Migrations\Schema\V111 |
||||
*/ |
||||
class Version20171002154600 extends AbstractMigrationChamilo |
||||
{ |
||||
/** |
||||
* @param Schema $schema |
||||
*/ |
||||
public function up(Schema $schema) |
||||
{ |
||||
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_registration', 'confirmation', 'MailConfirmation')"); |
||||
} |
||||
|
||||
/** |
||||
* @param Schema $schema |
||||
*/ |
||||
public function down(Schema $schema) |
||||
{ |
||||
$this->addSql("DELETE settings_options WHERE variable='allow_registration' AND value='confirmation' AND display_text='MailConfirmation'"); |
||||
} |
||||
} |
@ -0,0 +1,29 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php'; |
||||
|
||||
// Build the form |
||||
$form = new FormValidator('resend'); |
||||
$form->addElement('header', get_lang('ReSendConfirmationMail')); |
||||
$form->addText('user', get_lang('UserName'), true); |
||||
$form->addButtonSend(get_lang('Send')); |
||||
|
||||
if ($form->validate()) { |
||||
$values = $form->exportValues(); |
||||
|
||||
/** @var \Chamilo\UserBundle\Entity\User $thisUser */ |
||||
$thisUser = Database::getManager()->getRepository('ChamiloUserBundle:User')->findBy(['username' => $values['user']]); |
||||
|
||||
UserManager::sendUserConfirmationMail($thisUser); |
||||
Display::addFlash(Display::return_message(get_lang('EmailSend'))); |
||||
header('Location: '.api_get_path(WEB_PATH)); |
||||
exit; |
||||
} |
||||
|
||||
$tpl = new Template(null); |
||||
$tpl->assign('form', $form->toHtml()); |
||||
$content = $tpl->get_template('auth/resend_confirmation_mail.tpl'); |
||||
$tpl->assign('content', $tpl->fetch($content)); |
||||
$tpl->display_one_col_template(); |
||||
|
@ -0,0 +1,32 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php'; |
||||
|
||||
$token = isset($_GET['token']) ? $_GET['token'] : ''; |
||||
|
||||
if (!ctype_alnum($token)) { |
||||
$token = ''; |
||||
} |
||||
|
||||
/** @var \Chamilo\UserBundle\Entity\User $user */ |
||||
$user = UserManager::getManager()->findUserByConfirmationToken($token); |
||||
|
||||
if ($user) { |
||||
|
||||
$user->setActive(1); // Setted 1 to active the user |
||||
$user->setConfirmationToken(null); |
||||
|
||||
Database::getManager()->persist($user); |
||||
Database::getManager()->flush(); |
||||
|
||||
Display::addFlash(Display::return_message(get_lang('UserConfirmedNowYouCanLogInThePlatform'), 'success')); |
||||
header('Location: '.api_get_path(WEB_PATH)); |
||||
exit; |
||||
} else { |
||||
Display::addFlash( |
||||
Display::return_message(get_lang('LinkExpired')) |
||||
); |
||||
header('Location: '.api_get_path(WEB_PATH)); |
||||
exit; |
||||
} |
@ -0,0 +1 @@ |
||||
{{form}} |
Loading…
Reference in new issue