コード例 #1
0
ファイル: Views.php プロジェクト: Br3nda/indefero
 /**
  * Registration.
  *
  * We just ask for login, email and to agree with the terms. Then,
  * we go ahead and send a confirmation email. The confirmation
  * email will allow to set the password, first name and last name
  * of the user.
  */
 function register($request, $match)
 {
     $title = __('Create Your Account');
     $params = array('request' => $request);
     if ($request->method == 'POST') {
         $form = new IDF_Form_Register($request->POST, $params);
         if ($form->isValid()) {
             $user = $form->save();
             // It is sending the confirmation email
             $url = Pluf_HTTP_URL_urlForView('IDF_Views::registerInputKey');
             return new Pluf_HTTP_Response_Redirect($url);
         }
     } else {
         if (isset($request->GET['login'])) {
             $params['initial'] = array('login' => $request->GET['login']);
         }
         $form = new IDF_Form_Register(null, $params);
     }
     $context = new Pluf_Template_Context(array());
     $tmpl = new Pluf_Template('idf/terms.html');
     $terms = Pluf_Template::markSafe($tmpl->render($context));
     return Pluf_Shortcuts_RenderToResponse('idf/register/index.html', array('page_title' => $title, 'form' => $form, 'terms' => $terms), $request);
 }