2namespace dbx\dbxUser_admin;
4Class dbxUser_profil extends \dbxObj {
6 public function run($action) {
8 $oForm = dbx()->get_system_obj(
'dbxForm');
9 $oDB = dbx()->get_system_obj(
'dbxDB');
11 $uid = (int) dbx()->user();
12 $work = dbx()->get_modul_var(
'dbx_run2',
'',
'parameter');
14 $requestedRid = ($work ===
'new_user') ? 0 : (int) dbx()->get_request_var(
'rid', $uid,
'int');
15 if ($requestedRid < 0) {
19 $oForm->init(
'form-profil');
20 $oForm->set_workflow_scope(
'admin-profil-' . (
int) $requestedRid);
22 $oForm->_rid = (int) $rid;
23 $oForm->set_state_value(
'rid', (
int) $rid);
25 $data = $rid > 0 ? $oDB->select1($dd, $rid) : array(
'id' => 0);
27 if (!is_array($data)) {
28 return '<div class="alert alert-warning">Benutzerprofil nicht gefunden.</div>';
32 $oForm->_data = $data;
33 $oForm->_msg_info =
'Benutzerprofil bearbeiten';
35 $oForm->_action =
'?dbx_modul=dbxUser_admin&dbx_run1=user&dbx_run2=edit_profil&rid=' . $rid;
36 $oForm->add_rep(
'frame_skip_form_wrap',
'1');
37 $oForm->add_rep(
'frame_panel_class',
'dbxForm_wrapper dbx-user-profile-form');
38 $oForm->add_module_bar(
'Benutzerprofil',
'bi-person-badge');
39 $oForm->add_obj(
'bar_actions',
'obj-value',
'<small class="dbx-bar-meta">Stammdaten, Zugriff, Kontakt und Systemoptionen</small>');
41 $options_land = array(
43 'de' =>
'Deutschland',
44 'at' =>
'Oesterreich',
46 'us' =>
'United States'
49 $options_language = array(
54 $options_status = array(
61 $options_confirm = array(
66 $options_gender = array(
73 $options_anrede = array(
80 $oForm->add_fld(
'uname' ,
'text-label' );
81 $oForm->add_fld(
'pass' ,
'password-label', label:
'Passwort neu setzen', rules:
'password|max=32', placeholder:
'Leer lassen, wenn unveraendert');
82 $oForm->add_fld(
'status' ,
'select-single-label', options: $options_status);
83 $oForm->add_fld(
'is_confirm',
'select-single-label', label:
'Bestaetigt', options: $options_confirm);
84 $oForm->add_fld(
'roles' , label:
'Rollen', rules:
'array|parameter',
class:
'dbxMultiSelect2', data: array(
'size' => 8));
86 $oForm->add_fld(
'anrede' ,
'select-single-label', options: $options_anrede);
87 $oForm->add_fld(
'geschlecht',
'select-single-label', options: $options_gender);
88 $oForm->add_fld(
'name' ,
'text-label' );
89 $oForm->add_fld(
'name2' ,
'text-label' );
90 $oForm->add_fld(
'geburtstag',
'date-label' );
92 $oForm->add_fld(
'email' ,
'text-label' );
93 $oForm->add_fld(
'emailbill' ,
'text-label', label:
'Rechnungs-E-Mail');
94 $oForm->add_fld(
'telefon' ,
'text-label' );
95 $oForm->add_fld(
'handy' ,
'text-label' );
96 $oForm->add_fld(
'fax' ,
'text-label' );
98 $oForm->add_fld(
'strasse' ,
'text-label' );
99 $oForm->add_fld(
'land' ,
'select-single-label', options: $options_land);
100 $oForm->add_fld(
'plz' ,
'text-label' );
101 $oForm->add_fld(
'ort' ,
'text-label' );
103 $oForm->add_fld(
'language' ,
'select-single-label', options: $options_language);
104 $oForm->add_fld(
'design' ,
'text-label' );
105 $oForm->add_fld(
'color' ,
'text-label' );
106 $oForm->add_fld(
'login_pid' ,
'text-label', label:
'Login-Seite');
107 $oForm->add_fld(
'logout_pid',
'text-label', label:
'Logout-Seite');
109 if($oForm->submit()) {
110 if(!$oForm->errors()) {
111 $change = $oForm->changed();
113 $saveRid = (int) $rid;
114 $pas = $oForm->get_Post(
'pass',
'',
'password');
117 $oForm->_post[
'pass'] = md5($pas);
119 unset($oForm->_post[
'pass']);
123 unset($oForm->_post[
'id']);
126 $ok = $oForm->save_post($dd, $saveRid);
128 $rid = (int) $oForm->_rid;
129 $oForm->_action =
'?dbx_modul=dbxUser_admin&dbx_run1=user&dbx_run2=edit_profil&rid=' . $rid;
132 if ( $ok) $oForm->_msg_success =
'Benutzerdaten gespeichert';
133 if (!$ok) $oForm->_msg_error =
'Benutzerdaten konnten nicht gespeichert werden';
135 $oForm->_msg_success =
'Keine Aenderung';
139 foreach ($oForm->_errors as $key => $value) {
140 $err_flds .= $key .
' ';
142 $oForm->_msg_error =
'Pruefen Sie bitte Ihre Eingaben (' . $err_flds .
')';
146 $rid = $oForm->_data[
'id'] ?? $rid;
147 $oForm->add_obj(
'obs_rid',
'dbx|observe',
'name=usr_rid&value=' . (
int) $rid);
148 $oForm->add_obj(
'avatar',
'obj-value', dbx()->get_include_obj(
'dbxUser_avatar')->
run((
int) $rid));
150 $content = $oForm->run();