dbXapp 2.0
RAD, CMS, Module und Runtime-IDE fuer dbXapp
Loading...
Searching...
No Matches
dbxUser_profil.class.php
Go to the documentation of this file.
1<?php
2namespace dbx\dbxUser_admin;
3
4Class dbxUser_profil extends \dbxObj {
5
6 public function run($action) {
7 $content = '';
8 $oForm = dbx()->get_system_obj('dbxForm');
9 $oDB = dbx()->get_system_obj('dbxDB');
10 $dd = 'dbxUser';
11 $uid = (int) dbx()->user();
12 $work = dbx()->get_modul_var('dbx_run2', '', 'parameter');
13
14 $requestedRid = ($work === 'new_user') ? 0 : (int) dbx()->get_request_var('rid', $uid, 'int');
15 if ($requestedRid < 0) {
16 $requestedRid = $uid;
17 }
18
19 $oForm->init('form-profil');
20 $oForm->set_workflow_scope('admin-profil-' . (int) $requestedRid);
21 $rid = $requestedRid;
22 $oForm->_rid = (int) $rid;
23 $oForm->set_state_value('rid', (int) $rid);
24
25 $data = $rid > 0 ? $oDB->select1($dd, $rid) : array('id' => 0);
26
27 if (!is_array($data)) {
28 return '<div class="alert alert-warning">Benutzerprofil nicht gefunden.</div>';
29 }
30 $data['pass'] = '';
31
32 $oForm->_data = $data;
33 $oForm->_msg_info = 'Benutzerprofil bearbeiten';
34 $oForm->_dd = $dd;
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>');
40
41 $options_land = array(
42 '' => 'Auswahl...',
43 'de' => 'Deutschland',
44 'at' => 'Oesterreich',
45 'ch' => 'Schweiz',
46 'us' => 'United States'
47 );
48
49 $options_language = array(
50 'de' => 'Deutsch',
51 'en' => 'English'
52 );
53
54 $options_status = array(
55 0 => 'Neu',
56 1 => 'Aktiv',
57 2 => 'Gesperrt',
58 3 => 'Archiv'
59 );
60
61 $options_confirm = array(
62 0 => 'Nein',
63 1 => 'Ja'
64 );
65
66 $options_gender = array(
67 '' => 'Auswahl...',
68 'm' => 'Maennlich',
69 'w' => 'Weiblich',
70 'd' => 'Divers'
71 );
72
73 $options_anrede = array(
74 '' => 'Auswahl...',
75 'Herr' => 'Herr',
76 'Frau' => 'Frau',
77 'Divers' => 'Divers'
78 );
79
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));
85
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' );
91
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' );
97
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' );
102
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');
108
109 if($oForm->submit()) {
110 if(!$oForm->errors()) {
111 $change = $oForm->changed();
112 if ($change) {
113 $saveRid = (int) $rid;
114 $pas = $oForm->get_Post('pass', '', 'password');
115
116 if ($pas !== '') {
117 $oForm->_post['pass'] = md5($pas);
118 } else {
119 unset($oForm->_post['pass']);
120 }
121
122 if ($saveRid > 0) {
123 unset($oForm->_post['id']);
124 }
125
126 $ok = $oForm->save_post($dd, $saveRid);
127 if ($ok) {
128 $rid = (int) $oForm->_rid;
129 $oForm->_action = '?dbx_modul=dbxUser_admin&dbx_run1=user&dbx_run2=edit_profil&rid=' . $rid;
130 }
131
132 if ( $ok) $oForm->_msg_success = 'Benutzerdaten gespeichert';
133 if (!$ok) $oForm->_msg_error = 'Benutzerdaten konnten nicht gespeichert werden';
134 } else {
135 $oForm->_msg_success = 'Keine Aenderung';
136 }
137 } else {
138 $err_flds = '';
139 foreach ($oForm->_errors as $key => $value) {
140 $err_flds .= $key . ' ';
141 }
142 $oForm->_msg_error = 'Pruefen Sie bitte Ihre Eingaben (' . $err_flds . ')';
143 }
144 }
145
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));
149
150 $content = $oForm->run();
151 return $content;
152 }
153}
154
155?>