mirror of
https://github.com/myvesta/vesta.git
synced 2025-01-12 05:52:53 -08:00
62 lines
1.6 KiB
Bash
Executable File
62 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: change user language
|
|
# options: USER LANGUAGE
|
|
#
|
|
# The function for changing language.
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument defenition
|
|
user=$1
|
|
language=$2
|
|
|
|
# Includes
|
|
source $VESTA/func/main.sh
|
|
source $VESTA/conf/vesta.conf
|
|
|
|
|
|
is_language_valid() {
|
|
if [ ! -e "$VESTA/web/inc/i18n/$language.php" ]; then
|
|
echo "Error: language $language not exist"
|
|
log_event "$E_NOTEXIST $EVENT"
|
|
exit $E_NOTEXIST
|
|
fi
|
|
}
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
check_args '2' "$#" 'USER LANGUAGE'
|
|
validate_format 'user' 'language'
|
|
is_object_valid 'user' 'USER' "$user"
|
|
is_object_unsuspended 'user' 'USER' "$user"
|
|
is_language_valid $language
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Change language
|
|
if [ -z "$(grep LANGUAGE $USER_DATA/user.conf)" ]; then
|
|
sed -i "s/^TIME/LANGUAGE='$language'\nTIME/g" $USER_DATA/user.conf
|
|
else
|
|
update_user_value "$user" '$LANGUAGE' "$language"
|
|
fi
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
# Logging
|
|
log_history "changed language to $language"
|
|
log_event "$OK" "$EVENT"
|
|
|
|
exit
|