|
| 1 | +#!/bin/bash |
| 2 | +# info: updates user role |
| 3 | +# options: USER SORT_ORDER |
| 4 | +# labels: hestia |
| 5 | +# |
| 6 | +# example: v-change-user-sort-order user date |
| 7 | +# |
| 8 | +# Changes web UI display sort order for specified user. |
| 9 | + |
| 10 | +#----------------------------------------------------------# |
| 11 | +# Variable&Function # |
| 12 | +#----------------------------------------------------------# |
| 13 | + |
| 14 | +# Argument definition |
| 15 | +user=$1 |
| 16 | +sort_order=$2 |
| 17 | + |
| 18 | + |
| 19 | +# Includes |
| 20 | +# shellcheck source=/usr/local/hestia/func/main.sh |
| 21 | +source $HESTIA/func/main.sh |
| 22 | +# shellcheck source=/usr/local/hestia/conf/hestia.conf |
| 23 | +source $HESTIA/conf/hestia.conf |
| 24 | +# Unset THEME variable from $HESTIA/conf/hestia.conf |
| 25 | +unset THEME |
| 26 | + |
| 27 | + |
| 28 | +#----------------------------------------------------------# |
| 29 | +# Verifications # |
| 30 | +#----------------------------------------------------------# |
| 31 | + |
| 32 | +# Reading user values |
| 33 | +source $USER_DATA/user.conf |
| 34 | + |
| 35 | +is_format_valid 'user' 'theme' |
| 36 | +is_object_valid 'user' 'USER' "$user" |
| 37 | + |
| 38 | +is_object_unsuspended 'user' 'USER' "$user" |
| 39 | + |
| 40 | +# Perform verification if read-only mode is enabled |
| 41 | +check_hestia_demo_mode |
| 42 | + |
| 43 | +#----------------------------------------------------------# |
| 44 | +# Action # |
| 45 | +#----------------------------------------------------------# |
| 46 | + |
| 47 | +# Set theme value |
| 48 | +check_ckey=$(grep "PREF_UI_SORT" $USER_DATA/user.conf) |
| 49 | +if [ -z "$check_ckey" ]; then |
| 50 | + # Rebuild user configuration to repair missing value |
| 51 | + $BIN/v-rebuild-user $user |
| 52 | +fi |
| 53 | +update_user_value "$user" '$PREF_UI_SORT' "$sort_order" |
| 54 | + |
| 55 | +#----------------------------------------------------------# |
| 56 | +# Hestia # |
| 57 | +#----------------------------------------------------------# |
| 58 | + |
| 59 | +exit |
0 commit comments