Ejemplo n.º 1
0
 public function _loginForm()
 {
     $card = html::card();
     $card->add(html::cardHeader(lucid::$app->i18n()->translate('navigation:authentication.view.login')));
     $card->add(html::cardBlock());
     $card->lastChild()->add(html::form('authform', '#!authentication.controller.process'));
     $form = $card->lastChild()->lastChild();
     $form->add(html::formGroup(lucid::$app->i18n()->translate('model:users:email'), html::input('email', 'email')->preAddon('@')));
     $form->add(html::formGroup(lucid::$app->i18n()->translate('model:users:password'), html::input('password', 'password')->preAddon(html::icon('lock'))));
     $form->add(html::submit(lucid::$app->i18n()->translate('button:login'))->pull('right'));
     $this->ruleset('login')->send($form->name);
     return $card;
 }
Ejemplo n.º 2
0
 public function edit(int $role_id)
 {
     # By default, require that the user be logged in to access the edit form. If you want additional
     # permissions, use the lucid::$app->$security->requirePermission() function.
     #lucid::$app->permission()->requireLogin();
     # lucid::$app->$security->requirePermission('roles-select');
     # Set the title tag for the page. Optionally, you can also set the description or keywords meta tag
     # by calling lucid::$app->$response->description() or lucid::$app->$response->keywords()
     lucid::$app->response()->title(lucid::$app->i18n()->translate('branding:app_name') . ' - Roles');
     # Render the navigation controller.
     lucid::$app->factory()->view('navigation')->render('dashboard.view.admin', 'roles.view.table', 'roles.view.edit');
     # Load the model. If $role_id == 0, then the model's ->create method will be called.
     $data = $this->controller()->getOne($role_id);
     # the ->notFound method will throw an error if the first parameter === false, which will be the case
     # if the model function is passed an ID that is not zero, but is not able to retrieve a row for that ID
     #lucid::$app->$error->notFound($data, '#body');
     # Based on whether or not the primary key for the model == 0, the header message will either be the dictionary
     # key form:edit_new or form::edit_existing.
     $headerMsg = lucid::$app->i18n()->translate('form:edit_' . ($data->role_id == 0 ? 'new' : 'existing'), ['type' => 'roles', 'name' => $data->name]);
     # Construct the form and retrieve the ruleset for the controller. You can have multiple functions in your
     # controller if you want to have that controller accept submissions from different forms with different numbers
     # of fields, but the auto-generated ruleset-returning function is simply called ->ruleset(). The ->send()
     # method of the ruleset object packages up the rules into json, and sends them to the client so that they can be
     # used clientside when the form submits.
     $form = html::form('roles-edit', '#!roles.controller.save');
     $this->ruleset('edit')->send($form->name);
     # create the main structure for the form
     $card = html::card();
     $card->header()->add($headerMsg);
     $card->block()->add([html::formGroup(lucid::$app->i18n()->translate('model:roles:name'), html::input('text', 'name', $data->name)), html::input('hidden', 'role_id', $data->role_id)]);
     $card->footer()->add(html::formButtons());
     $form->add($card);
     lucid::$app->response()->replace('#main-rightcol', $form);
 }
Ejemplo n.º 3
0
 public function edit(int $user_id)
 {
     # By default, require that the user be logged in to access the edit form. If you want additional
     # permissions, use the lucid::$app->$security->requirePermission() function.
     #lucid::$app->permission()->requireLogin();
     # lucid::$app->$security->requirePermission('users-select');
     # Set the title tag for the page. Optionally, you can also set the description or keywords meta tag
     # by calling lucid::$app->$response->description() or lucid::$app->$response->keywords()
     lucid::$app->response()->title(lucid::$app->i18n()->translate('branding:app_name') . ' - Users');
     # Render the navigation controller.
     lucid::$app->factory()->view('navigation')->render('users.view.table', 'users.view.edit');
     # Load the model. If $user_id == 0, then the model's ->create method will be called.
     $data = $this->controller()->getOne($user_id);
     # the ->notFound method will throw an error if the first parameter === false, which will be the case
     # if the model function is passed an ID that is not zero, but is not able to retrieve a row for that ID
     #lucid::$app->$error->notFound($data, '#body');
     # Based on whether or not the primary key for the model == 0, the header message will either be the dictionary
     # key form:edit_new or form::edit_existing.
     $headerMsg = lucid::$app->i18n()->translate('form:edit_' . ($data->user_id == 0 ? 'new' : 'existing'), ['type' => 'users', 'name' => $data->email]);
     # Construct the form and retrieve the ruleset for the controller. You can have multiple functions in your
     # controller if you want to have that controller accept submissions from different forms with different numbers
     # of fields, but the auto-generated ruleset-returning function is simply called ->ruleset(). The ->send()
     # method of the ruleset object packages up the rules into json, and sends them to the client so that they can be
     # used clientside when the form submits.
     $form = html::form('users-edit', '#!users.controller.save');
     $this->ruleset('edit')->send($form->name);
     $org_id_options = lucid::$app->factory()->model('organizations')->select('org_id', 'value')->select('name', 'label')->order_by_asc('name')->find_array();
     $org_id_options = array_merge([0, ''], $org_id_options);
     # create the main structure for the form
     $card = html::card();
     $card->header()->add($headerMsg);
     $card->block()->add([html::formGroup(lucid::$app->i18n()->translate('model:users:org_id'), html::select('org_id', $data->org_id, $org_id_options)), html::formGroup(lucid::$app->i18n()->translate('model:users:email'), html::input('text', 'email', $data->email)), html::formGroup(lucid::$app->i18n()->translate('model:users:password'), html::input('text', 'password', $data->password)), html::formGroup(lucid::$app->i18n()->translate('model:users:first_name'), html::input('text', 'first_name', $data->first_name)), html::formGroup(lucid::$app->i18n()->translate('model:users:last_name'), html::input('text', 'last_name', $data->last_name)), html::formGroup(lucid::$app->i18n()->translate('model:users:is_enabled'), html::input('checkbox', 'is_enabled', $data->is_enabled)), html::formGroup(lucid::$app->i18n()->translate('model:users:last_login'), html::input('date', 'last_login', (new \DateTime($data->last_login))->format('Y-m-d H:i'))), html::formGroup(lucid::$app->i18n()->translate('model:users:created_on'), html::input('date', 'created_on', (new \DateTime($data->created_on))->format('Y-m-d H:i'))), html::formGroup(lucid::$app->i18n()->translate('model:users:force_password_change'), html::input('checkbox', 'force_password_change', $data->force_password_change)), html::formGroup(lucid::$app->i18n()->translate('model:users:register_key'), html::input('text', 'register_key', $data->register_key)), html::input('hidden', 'user_id', $data->user_id)]);
     $card->footer()->add(html::formButtons());
     $form->add($card);
     lucid::$app->response()->replace('#main-fullwidth', $form);
 }