Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support to new register page (for 3.5.2)
- Loading branch information
Kousuke Ebihara
committed
Apr 29, 2010
1 parent
6bbabd5
commit 34d1a6f
Showing
8 changed files
with
186 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
apps/pc_frontend/modules/opAuthMailAddress/actions/components.class.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the OpenPNE package. | ||
* (c) OpenPNE Project (http://www.openpne.jp/) | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file and the NOTICE file that were distributed with this source code. | ||
*/ | ||
|
||
class opAuthMailAddressComponents extends sfComponents | ||
{ | ||
public function executeRegisterBox($request) | ||
{ | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
apps/pc_frontend/modules/opAuthMailAddress/config/security.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
registerEnd: | ||
is_secure: on | ||
credentials: SNSRegisterFinish | ||
is_secure: false |
7 changes: 7 additions & 0 deletions
7
apps/pc_frontend/modules/opAuthMailAddress/templates/_registerBox.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php op_include_parts('ButtonBox', 'opAuthMailAddressPluginRegisterBox', array( | ||
'title' => 'メールアドレスで登録する', | ||
'body' => '以下のボタンをクリックすると、招待されたメールアドレスで登録をおこないます。', | ||
'button' => 'プロフィール入力ページへ', | ||
'url' => url_for($sf_user->getRegisterInputAction()), | ||
'method' => 'get', | ||
)) ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ public function doSave() | |
} | ||
|
||
$memberConfig->save(); | ||
|
||
return $memberConfig; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the OpenPNE package. | ||
* (c) OpenPNE Project (http://www.openpne.jp/) | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file and the NOTICE file that were distributed with this source code. | ||
*/ | ||
|
||
/** | ||
* | ||
* | ||
* @package opAuthMailAddressPlugin | ||
* @subpackage form | ||
* @author Kousuke Ebihara <ebihara@tejimaya.com> | ||
*/ | ||
class opRequestRegisterURLForm extends BaseForm | ||
{ | ||
protected $doNotSend = false; | ||
|
||
public function configure() | ||
{ | ||
$this->disableLocalCSRFProtection(); | ||
|
||
$this->setWidget('mail_address', new sfWidgetFormInputText()); | ||
$this->setValidator('mail_address', new sfValidatorPass()); | ||
|
||
$callback = new sfValidatorCallback(array( | ||
'callback' => array($this, 'validate'), | ||
)); | ||
$callback->setMessage('invalid', 'invalid e-mail address'); | ||
$this->validatorSchema->setPostValidator($callback); | ||
|
||
if (sfConfig::get('op_is_use_captcha', false)) | ||
{ | ||
$this->embedForm('captcha', new opCaptchaForm()); | ||
} | ||
|
||
$this->widgetSchema->setNameFormat('request_register_url[%s]'); | ||
} | ||
|
||
public function validate($validator, $values, $arguments = array()) | ||
{ | ||
if (opToolkit::isMobileEmailAddress($values['mail_address'])) | ||
{ | ||
$mailValidator = new sfValidatorMobileEmail(); | ||
$values['mobile_address'] = $mailValidator->clean($values['mail_address']); | ||
$mode = 'mobile'; | ||
} | ||
else | ||
{ | ||
$mailValidator = new opValidatorPCEmail(); | ||
$values['pc_address'] = $mailValidator->clean($values['mail_address']); | ||
$mode = 'pc'; | ||
} | ||
|
||
if (!opToolkit::isEnabledRegistration($mode)) | ||
{ | ||
throw new sfValidatorError($validator, 'invalid'); | ||
} | ||
|
||
if (!empty($values['mobile_address']) && !$this->validateAddress('mobile_address', $values['mobile_address'])) | ||
{ | ||
$this->doNotSend = true; | ||
} | ||
if (!empty($values['pc_address']) && !$this->validateAddress('pc_address', $values['pc_address'])) | ||
{ | ||
$this->doNotSend = true; | ||
} | ||
|
||
return $values; | ||
} | ||
|
||
protected function validateAddress($configName, $configValue) | ||
{ | ||
if ($config = Doctrine::getTable('MemberConfig')->retrieveByNameAndValue($configName, $configValue)) | ||
{ | ||
return false; | ||
} | ||
elseif ($config = Doctrine::getTable('MemberConfig')->retrieveByNameAndValue($configName.'_pre', $configValue)) | ||
{ | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public function sendMail() | ||
{ | ||
if ($this->doNotSend) | ||
{ | ||
return null; | ||
} | ||
|
||
$address = ''; | ||
|
||
$member = Doctrine::getTable('Member')->createPre(); | ||
|
||
if ($this->getValue('pc_address')) | ||
{ | ||
$address = $this->getValue('pc_address'); | ||
|
||
$member->setConfig('pc_address_pre', $address); | ||
} | ||
elseif ($this->getValue('mobile_address')) | ||
{ | ||
$address = $this->getValue('mobile_address'); | ||
|
||
$member->setConfig('mobile_address_pre', $address); | ||
} | ||
|
||
$token = $member->generateRegisterToken(); | ||
|
||
$authMode = $this->getOption('authMode', null); | ||
if (!$authMode) | ||
{ | ||
$authMode = sfContext::getInstance()->getUser()->getCurrentAuthMode(); | ||
} | ||
$member->setConfig('register_auth_mode', $authMode); | ||
|
||
$params = array( | ||
'token' => $token, | ||
'authMode' => 'MailAddress', | ||
'isMobile' => opToolkit::isMobileEmailAddress($address), | ||
'subject' => opConfig::get('sns_name').'招待状', | ||
); | ||
opMailSend::sendTemplateMail('notifyRegisterURL', $address, opConfig::get('admin_mail_address'), $params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php $snsName = $op_config['sns_name'] ?> | ||
<?php echo __('Hello! This is information from %1%.', array('%1%' => $snsName)) ?> | ||
|
||
<?php echo __('If you register(free) of member by the following URL,%br%you can participate in %1%.', array('%1%' => $snsName, '%br%' => "\n")) ?> | ||
|
||
<?php echo __('* Participate in %1%', array('%1%' => $snsName)) ?> | ||
|
||
<?php if ($isMobile) : ?> | ||
<?php echo app_url_for('mobile_frontend', sprintf('opAuthMailAddress/register?token=%s&authMode=%s', $token, $authMode), true) ?> | ||
<?php else: ?> | ||
<?php echo app_url_for('pc_frontend', sprintf('opAuthMailAddress/register?token=%s&authMode=%s', $token, $authMode), true) ?> | ||
<?php endif; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php $snsName = $op_config['sns_name'] ?> | ||
<?php echo __('Hello! This is information from %1%.', array('%1%' => $snsName)) ?> | ||
|
||
<?php echo __('If you register(free) of member by the following URL,%br%you can participate in %1%.', array('%1%' => $snsName, '%br%' => "\n")) ?> | ||
|
||
<?php echo __('* Participate in %1%', array('%1%' => $snsName)) ?> | ||
|
||
|
||
|
||
<?php if ($isMobile) : ?> | ||
<?php echo app_url_for('mobile_frontend', sprintf('opAuthMailAddress/register?token=%s&authMode=%s', $token, $authMode), true) ?> | ||
<?php else: ?> | ||
<?php echo app_url_for('pc_frontend', sprintf('opAuthMailAddress/register?token=%s&authMode=%s', $token, $authMode), true) ?> | ||
<?php endif; ?> |