コード例 #1
0
ファイル: copy.blade.php プロジェクト: juaniiie/mwi
            <div class="control-group {{ $errors->has('slug') ? 'error' : '' }}">
                <label class="control-label" for="slug">{{ Lang::line('email::lang.Slug')->get(ADM_LANG) }}</label>
                <div class="controls">
                    {{ Form::text('slug', $template->slug) }}
                    <span class="required-icon"></span>
                    @if(isset($errors) and $errors->has('slug'))
                    <span class="help-inline">{{ $errors->first('slug') }}</span>
                    @endif
                </div>
            </div>

            <div class="control-group {{ $errors->has('lang') ? 'error' : '' }}">
                <label class="control-label" for="lang">{{ Lang::line('email::lang.Language')->get(ADM_LANG) }}</label>
                <div class="controls">
                    <?php 
$langs = json_decode(Settings\Config::get('settings::core.available_languages'), true);
?>
                    {{ Form::select('lang', $langs, $template->lang) }}
                    @if(isset($errors) and $errors->has('lang'))
                    <span class="help-inline">{{ $errors->first('lang') }}</span>
                    @endif
                </div>
            </div>

            <div class="control-group {{ $errors->has('type') ? 'error' : '' }}">
                <label class="control-label" for="type">{{ Lang::line('email::lang.Type')->get(ADM_LANG) }}</label>
                <div class="controls">
                    {{ Form::select('type', array('html' => 'HTML', 'text' => Lang::line('email::lang.Plain Text')->get(ADM_LANG)), $template->lang) }}
                    @if(isset($errors) and $errors->has('type'))
                    <span class="help-inline">{{ $errors->first('type') }}</span>
                    @endif
コード例 #2
0
ファイル: registration.php プロジェクト: juaniiie/mwi
 public function post_create()
 {
     $messages = array('unique_avatar_name' => 'This combination of avatar first name and avatar last name has already been taken.');
     $rules = array('email' => 'required|email|unique:users', 'username' => 'required|unique:users|alpha_dash|max:30|min:3', 'avatar_first_name' => 'required|alpha_dash|max:30|min:3|unique_avatar_name', 'avatar_last_name' => 'required|alpha_dash|max:30|min:3', 'password' => 'required|min:8', 'password_confirmation' => 'required|same:password');
     Validator::register('unique_avatar_name', function ($attribute, $value, $parameters) {
         $user = Users\Model\User::where('avatar_first_name', '=', Input::get('avatar_first_name'))->where('avatar_last_name', '=', Input::get('avatar_last_name'))->first();
         if (isset($user) and !empty($user)) {
             return false;
         }
         return true;
     });
     $validation = Validator::make(Input::all(), $rules, $messages);
     if ($validation->passes()) {
         $group_id = 0;
         if (Bundle::exists('groups')) {
             $users_group = Groups\Model\Group::where('slug', '=', 'users')->first();
             if (isset($users_group->id) and ctype_digit($users_group->id)) {
                 $group_id = $users_group->id;
             }
         }
         $new_user = new Users\Model\User();
         $new_user->status = 'inactive';
         $require_confirmation = Config::get('settings::core.registration_confirmation_required');
         if ($require_confirmation == 'no') {
             $new_user->status = 'active';
         }
         $password = Users\Helper::hash_password(Input::get('password'));
         $new_user->uuid = Mwi_Core::random_uuid();
         $new_user->email = Input::get('email');
         $new_user->username = Input::get('username');
         $new_user->avatar_first_name = Input::get('avatar_first_name');
         $new_user->avatar_last_name = Input::get('avatar_last_name');
         $new_user->group_id = $group_id;
         $new_user->hash = $password['hash'];
         $new_user->salt = $password['salt'];
         $new_user->password = Hash::make(Input::get('password'));
         $new_user->save();
         Event::fire('registration.user_signup', array($new_user));
         //Event for Robust
         Event::fire('users.created', array($new_user));
         if ($require_confirmation == 'no') {
             Auth::login($new_user->id);
             Event::fire('registration.user_activated', array($new_user));
             //Event for Robust
             Event::fire('users.updated', array($new_user));
             $site_name = Settings\Config::get('settings::core.site_name');
             $this->data['message'] = Lang::line('registration::lang.welcome_signup', array('site_name' => $site_name))->get(APP_LANG);
             $this->data['message_type'] = 'success';
             return Redirect::to('page/home')->with($this->data);
         } else {
             // save activation record on database
             $activation_record = new Registration\Model\Code();
             $activation_record->user_id = $new_user->id;
             $activation_record->code = Mwi_Core::keygen();
             $activation_record->save();
             // new xblade to parse the email template
             $xblade = new Xblade();
             $xblade->scopeGlue(':');
             // data to be passed to email template
             $data['user'] = $new_user;
             $data['activation_code'] = $activation_record->code;
             $data['url']['base'] = URL::base();
             $data['settings']['site_name'] = Config::get('settings::core.site_name');
             $data['request']['ip'] = Request::ip();
             $data['request']['user_agent'] = implode(', ', Request::header('user-agent'));
             $data['request']['languages'] = implode(', ', Request::languages());
             // get email template based on settings
             $email_address = Config::get('settings::core.server_email');
             $template_id = Config::get('settings::core.registration_email_template');
             $email_data = Email\Model\Template::find($template_id);
             //send email to user
             Email\Message::to($new_user->email)->from($email_address)->subject($xblade->parse($email_data->subject, $data))->body($xblade->parse($email_data->body, $data))->html($email_data->type)->send();
             $this->data['message'] = __('registration::lang.Thank you Please check your email to activate your new account')->get(APP_LANG);
             $this->data['message_type'] = 'success';
             return Redirect::to('page/home')->with($this->data);
         }
     }
     return Redirect::to('signup')->with_errors($validation)->with_input();
 }