@@ -25,7 +25,7 @@ public function __construct()
2525 */
2626 public function create_user ($ username , $ name , $ email , $ password , $ isAdmin = 0 )
2727 {
28- if ($ this ->nodes ()->checkNode ("benutzer.inc " , "create_user " ) == false ){
28+ if ($ this ->nodes ()->checkNode ("benutzer.inc " , "create_user " ) == false ) {
2929 return false ;
3030 }
3131 Exceptions::error_rep ("Creating user ' $ username'... " );
@@ -47,20 +47,44 @@ public function create_user($username, $name, $email, $password, $isAdmin = 0)
4747 }
4848 }
4949
50- public function user_active ($ username ){
50+ public function renderUserSelect (string $ name , ?int $ selectedUser = null , string $ noAssigneeText = "— " ): void
51+ {
52+ $ users = $ this ->get_all_users ();
53+
54+ echo '<select name=" ' . htmlspecialchars ($ name ) . '"> ' ;
55+
56+ // First “no assignee” option
57+ echo '<option value=""> ' . htmlspecialchars ($ noAssigneeText ) . '</option> ' ;
58+
59+ // Users
60+ foreach ($ users as $ u ) {
61+ $ sel = ($ selectedUser !== null && $ u ["id " ] == $ selectedUser ) ? ' selected ' : '' ;
62+ echo '<option value=" ' . $ u ["id " ] . '" ' . $ sel . '> '
63+ . htmlspecialchars ($ u ["name " ])
64+ . '</option> ' ;
65+ }
66+
67+ echo '</select> ' ;
68+ }
69+
70+
71+ public function user_active ($ username )
72+ {
5173 $ user = $ this ->get_user ($ username );
52- if ($ user ["active " ] == true || $ user ["active " ] == 1 ){
74+ if ($ user ["active " ] == true || $ user ["active " ] == 1 ) {
5375 return true ;
5476 } else {
5577 return false ;
5678 }
5779 }
5880
59- public function activate_user ($ username ){
81+ public function activate_user ($ username )
82+ {
6083 return $ this ->editUserProperties ($ username , "active " , 1 );
6184 }
6285
63- public function deactivate_user ($ username ){
86+ public function deactivate_user ($ username )
87+ {
6488 return $ this ->editUserProperties ($ username , "active " , 0 );
6589 }
6690
@@ -74,10 +98,10 @@ public function deactivate_user($username){
7498 */
7599 public function delete_user ($ id )
76100 {
77- if ($ this ->nodes ()->checkNode ("benutzer.inc " , "delete_user " ) == false ){
101+ if ($ this ->nodes ()->checkNode ("benutzer.inc " , "delete_user " ) == false ) {
78102 return false ;
79103 }
80- $ user = $ this ->get_user_from_id ($ id );
104+ $ user = $ this ->get_user_from_id ($ id );
81105 $ username = $ user ["username " ];
82106 $ email = $ user ["email " ];
83107 Exceptions::error_rep ("Deleting user with id ' $ id'... " );
@@ -217,7 +241,7 @@ public function get_all_users()
217241 */
218242 public function get_all_users_html ()
219243 {
220- if ($ this ->nodes ()->checkNode ("benutzer.inc " , "get_all_users_html " ) == false ){
244+ if ($ this ->nodes ()->checkNode ("benutzer.inc " , "get_all_users_html " ) == false ) {
221245 return false ;
222246 }
223247 Exceptions::error_rep ("Getting all users... " );
@@ -264,7 +288,7 @@ public function get_all_users_html()
264288 */
265289 public function get_user_html ($ username )
266290 {
267- if ($ this ->nodes ()->checkNode ("benutzer.inc " , "get_user_html " ) == false ){
291+ if ($ this ->nodes ()->checkNode ("benutzer.inc " , "get_user_html " ) == false ) {
268292 return false ;
269293 }
270294 Exceptions::error_rep ("Getting user ' $ username'... " );
@@ -314,25 +338,28 @@ public static function is_admin($user)
314338 }
315339 }
316340
317- public static function current_user_is_admin (){
318- if (self ::get_current_user ()["isAdmin " ] == true ){
341+ public static function current_user_is_admin ()
342+ {
343+ if (self ::get_current_user ()["isAdmin " ] == true ) {
319344 return true ;
320345 } else {
321346 return false ;
322347 }
323348 }
324349
325- public static function get_current_user (){
350+ public static function get_current_user ()
351+ {
326352 return self ::get_user ($ _SESSION ["username " ]);
327353 }
328354
329- public static function get_name_from_id ($ id ){
355+ public static function get_name_from_id ($ id )
356+ {
330357 return self ::get_user_from_id ($ id )["name " ];
331358 }
332359
333360 public function editUserProperties (mixed $ username_or_id , string $ name , mixed $ value ): bool
334361 {
335- if ($ this ->nodes ()->checkNode ("benutzer.inc " , "editUserProperties " ) == false ){
362+ if ($ this ->nodes ()->checkNode ("benutzer.inc " , "editUserProperties " ) == false ) {
336363 return false ;
337364 }
338365 if (
@@ -378,28 +405,30 @@ public function editUserProperties(mixed $username_or_id, string $name, mixed $v
378405 }
379406 }
380407
381- public function loadUserTheme (){
408+ public function loadUserTheme ()
409+ {
382410
383411 $ themes = scandir ($ _SERVER ["DOCUMENT_ROOT " ] . "/assets/css " );
384412 $ themes = array_diff ($ themes , [". " , ".. " ]);
385413 $ check = in_array ($ _COOKIE ["theme " ], $ themes );
386- if ($ this ->get_app_ini ()["general " ]["force_theme " ] == "true " ){
414+ if ($ this ->get_app_ini ()["general " ]["force_theme " ] == "true " ) {
387415 return $ this ->get_app_ini ()["general " ]["theme_file " ];
388416 }
389417
390- if (!isset ($ _COOKIE ["theme " ]) || !$ check ){
418+ if (!isset ($ _COOKIE ["theme " ]) || !$ check ) {
391419 return "/assets/css/v8.css " ;
392420 } else {
393421 return "/assets/css/ " . $ _COOKIE ["theme " ];
394422 }
395423 }
396424
397- public function computeUserThemes (){
425+ public function computeUserThemes ()
426+ {
398427 $ themes = scandir ($ _SERVER ["DOCUMENT_ROOT " ] . "/assets/css " );
399428 $ themes = array_diff ($ themes , [". " , ".. " ]);
400429 $ currentTheme = basename ($ this ->loadUserTheme ());
401- foreach ($ themes as $ theme ){
402- if ($ currentTheme == $ theme ){
430+ foreach ($ themes as $ theme ) {
431+ if ($ currentTheme == $ theme ) {
403432 echo "<option name=' {$ theme }' selected> {$ theme }</option> " ;
404433 } else {
405434 echo "<option name=' {$ theme }'> {$ theme }</option> " ;
@@ -409,13 +438,15 @@ public function computeUserThemes(){
409438 return true ;
410439 }
411440
412- public function setUserTheme ($ theme ){
413- setcookie ("theme " , $ theme , time ()+60 *60 *24 *30 , "/ " );
441+ public function setUserTheme ($ theme )
442+ {
443+ setcookie ("theme " , $ theme , time () + 60 * 60 * 24 * 30 , "/ " );
414444 return true ;
415445 }
416446
417- public function checkThemeForce (){
418- if ($ this ->get_app_ini ()["general " ]["force_theme " ] == "true " || $ this ->get_app_ini ()["general " ]["force_theme " ] == true ){
447+ public function checkThemeForce ()
448+ {
449+ if ($ this ->get_app_ini ()["general " ]["force_theme " ] == "true " || $ this ->get_app_ini ()["general " ]["force_theme " ] == true ) {
419450 return true ;
420451 } else {
421452 return false ;
0 commit comments