Added the initialisation of the user language at registration time.
When the user register, we grab the language from the browser and use it as first value for the corresponding user object. The user can then later on modify it from his account area.
This commit is contained in:
parent
f6fb6c5ccc
commit
d292678759
@ -27,8 +27,11 @@
|
|||||||
*/
|
*/
|
||||||
class IDF_Form_Register extends Pluf_Form
|
class IDF_Form_Register extends Pluf_Form
|
||||||
{
|
{
|
||||||
|
protected $request;
|
||||||
|
|
||||||
public function initFields($extra=array())
|
public function initFields($extra=array())
|
||||||
{
|
{
|
||||||
|
$this->request = $extra['request'];
|
||||||
$login = '';
|
$login = '';
|
||||||
if (isset($extra['initial']['login'])) {
|
if (isset($extra['initial']['login'])) {
|
||||||
$login = $extra['initial']['login'];
|
$login = $extra['initial']['login'];
|
||||||
@ -115,6 +118,7 @@ class IDF_Form_Register extends Pluf_Form
|
|||||||
$user->last_name = $this->cleaned_data['login'];
|
$user->last_name = $this->cleaned_data['login'];
|
||||||
$user->login = $this->cleaned_data['login'];
|
$user->login = $this->cleaned_data['login'];
|
||||||
$user->email = $this->cleaned_data['email'];
|
$user->email = $this->cleaned_data['email'];
|
||||||
|
$user->language = $this->request->language_code;
|
||||||
$user->active = false;
|
$user->active = false;
|
||||||
$user->create();
|
$user->create();
|
||||||
$from_email = Pluf::f('from_email');
|
$from_email = Pluf::f('from_email');
|
||||||
|
@ -63,6 +63,7 @@ class IDF_Form_RegisterConfirmation extends Pluf_Form
|
|||||||
'size' => 15,
|
'size' => 15,
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->fields['password'] = new Pluf_Form_Field_Varchar(
|
$this->fields['password'] = new Pluf_Form_Field_Varchar(
|
||||||
array('required' => true,
|
array('required' => true,
|
||||||
'label' => __('Your password'),
|
'label' => __('Your password'),
|
||||||
|
@ -84,16 +84,19 @@ class IDF_Views
|
|||||||
function register($request, $match)
|
function register($request, $match)
|
||||||
{
|
{
|
||||||
$title = __('Create Your Account');
|
$title = __('Create Your Account');
|
||||||
|
$params = array('request'=>$request);
|
||||||
if ($request->method == 'POST') {
|
if ($request->method == 'POST') {
|
||||||
$form = new IDF_Form_Register($request->POST);
|
$form = new IDF_Form_Register($request->POST, $params);
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
$user = $form->save(); // It is sending the confirmation email
|
$user = $form->save(); // It is sending the confirmation email
|
||||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views::registerInputKey');
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views::registerInputKey');
|
||||||
return new Pluf_HTTP_Response_Redirect($url);
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$init = (isset($request->GET['login'])) ? array('initial' => array('login' => $request->GET['login'])) : array();
|
if (isset($request->GET['login'])) {
|
||||||
$form = new IDF_Form_Register(null, $init);
|
$params['initial'] = array('login' => $request->GET['login']);
|
||||||
|
}
|
||||||
|
$form = new IDF_Form_Register(null, $params);
|
||||||
}
|
}
|
||||||
$context = new Pluf_Template_Context(array());
|
$context = new Pluf_Template_Context(array());
|
||||||
$tmpl = new Pluf_Template('idf/terms.html');
|
$tmpl = new Pluf_Template('idf/terms.html');
|
||||||
|
Loading…
Reference in New Issue
Block a user