Esempio n. 1
0
 /**
  * Updates an existing row or inserts a new row into table vw_users_details.
  *
  * @param string $user_id
  * @param string $email
  * @param string $password
  * @param string $first_name
  * @param string $last_name
  * @param string $org_id
  * @param string $organization_name
  * @param string $role_id
  * @param string $role_name
  * @param bool $do_redirect Determines whether or not to redirect back to the data table view.
  *
  * @return void
  */
 public function save(string $user_id, string $email, string $password, string $first_name, string $last_name, string $org_id, string $organization_name, string $role_id, string $role_name, bool $do_redirect = true)
 {
     #lucid::permission()->requireLogin();
     # lucid::$security->requirePermission([]); # add required permissions to this array
     # This will check the parameters passed to this function, and run them against the rules returned
     # from ->ruleset(). If the data does not pass validation, an error message is sent to the client
     # and the request ends. If the data passes validation, then processing continues. You do not
     # need to check if the data passes or not.
     $this->ruleset('edit')->checkParameters(func_get_args());
     # This loads the table row that you are trying to update. If $user_id === 0, then the model's
     # ->create() method will be called. This does not actually insert a row into the database until the
     # ->save() method is called.
     $data = $this->getOne($user_id);
     $data->email = $email;
     $data->password = $password;
     $data->first_name = $first_name;
     $data->last_name = $last_name;
     $data->org_id = $org_id;
     $data->organization_name = $organization_name;
     $data->role_id = $role_id;
     $data->role_name = $role_name;
     $data->save();
     lucid::response()->message(lucid::$app->i18n()->translate('button:save_response'));
     if ($do_redirect === true) {
         lucid::$app->response()->redirect('vw_users_details', 'table');
     }
 }
Esempio n. 2
0
<?php

use Lucid\Lucid;
include __DIR__ . '/../bootstrap.php';
# This respone class's output is a bit prettier for the command line
lucid::setComponent('response', new \Lucid\Component\Response\CommandLine());
# Since cookies cannot be written when called on the command line, replace the cookie store
# with a generic store.
lucid::setComponent('cookie', new \Lucid\Component\Store\Store());
lucid::queue()->parseCommandLineAction($argv);
lucid::queue()->process();
lucid::response()->write();