Premier commit

This commit is contained in:
2024-09-09 10:22:45 +02:00
commit bcc2604080
74 changed files with 25819 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
<?php
namespace app\overrides\user\controllers;
use app\overrides\user\models\User;
use function Piko\I18n\__;
use app\modules\user\models\Role;
class AdminController extends \app\modules\user\controllers\AdminController
{
/**
* Render User form and create or update user
*
* @return string
*/
public function editAction(int $id = 0)
{
$user = new User($this->db);
if ($id) {
$user->load($id);
}
$user->scenario = User::SCENARIO_ADMIN;
$message = [];
$post = $this->request->getParsedBody();
if (!empty($post)) {
$user->bind($post);
if ($user->isValid() && $user->save()) {
$message['type'] = 'success';
$message['content'] = __('user', 'User successfully saved');
} else {
$message['type'] = 'danger';
$message['content'] = __('user', 'Save error!') . implode(' ', $user->errors);
}
}
return $this->render('edit', [
'user' => $user,
'message' => $message,
'roles' => Role::find('`name` ASC'),
]);
}
}