mirror of
https://github.com/myvesta/vesta
synced 2025-08-14 02:28:05 -07:00
user notification backend
This commit is contained in:
parent
aa558a66c0
commit
b560c99ceb
7 changed files with 303 additions and 1 deletions
66
bin/v-delete-user-notification
Executable file
66
bin/v-delete-user-notification
Executable file
|
@ -0,0 +1,66 @@
|
|||
#!/bin/bash
|
||||
# info: delete user notification
|
||||
# options: USER NOTIFICATION
|
||||
#
|
||||
# The function deletes user notification.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
nid=$2
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER NOTIFICATION'
|
||||
validate_format 'user' 'nid'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Deleting notification
|
||||
sed -i "/NID='$nid' /d" $USER_DATA/notifications.conf 2>/dev/null
|
||||
|
||||
# Checking last notification
|
||||
if [ -e "$USER_DATA/notifications.conf" ]; then
|
||||
if [ -z "$(grep NID= $USER_DATA/notifications.conf)" ]; then
|
||||
notice='no'
|
||||
fi
|
||||
if [ -z "$(grep "ACK='no'" $USER_DATA/notifications.conf)" ]; then
|
||||
notice='no'
|
||||
fi
|
||||
else
|
||||
notice='no'
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Updating notification counter
|
||||
if [ "$notice" = 'no' ]; then
|
||||
if [ -z "$(grep NOTIFICATIONS $USER_DATA/user.conf)" ]; then
|
||||
sed -i "s/^TIME/NOTIFICATIONS='no'\nTIME/g" $USER_DATA/user.conf
|
||||
else
|
||||
update_user_value "$user" '$NOTIFICATIONS' "no"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
Loading…
Add table
Add a link
Reference in a new issue