Merge branch 'master' of github.com:serghey-rodin/vesta

This commit is contained in:
larsz 2012-01-11 01:17:27 +02:00
commit bff632a2ad
38 changed files with 1641 additions and 1224 deletions

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: adding system user
# info: add system user
# options: user password email [package] [fname] [lname]
#
# The function creates new user account.
#----------------------------------------------------------#
# Variable&Function #
@ -56,10 +60,11 @@ is_package_valid "$package"
package_data=$(cat $V_PKG/$package.pkg)
# Checking shell
shell_conf=$(echo "$package_data"|grep 'SHELL'|cut -f 2 -d \')
shell_conf=$(echo "$package_data" | grep 'SHELL' | cut -f 2 -d \')
case $shell_conf in
nologin) shell='/sbin/nologin' ;;
bash) shell='/bin/bash' ;;
sh) shell='/bin/bash' ;;
*) shell='/sbin/nologin' ;;
esac
@ -95,8 +100,8 @@ chmod -R a+x $V_HOME/$user
# Checking quota
if [ ! -z "$DISK_QUOTA" ] && [ "$DISK_QUOTA" != 'no' ]; then
DISK_QUOTA=$(echo "$package_data"|grep 'DISK_QUOTA' | cut -f 2 -d \')
set_quota "$user" "$DISK_QUOTA"
DISK_QUOTA=$(echo "$package_data" | grep 'DISK_QUOTA' | cut -f 2 -d \')
#$V_BIN/v_add_user_quota "$user" "$DISK_QUOTA"
fi

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: schedule user backup
# info: schedule user backup creation
# options: user
#
# The function for scheduling user backup creation.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,10 @@
#!/bin/bash
# info: adding user reports
# info: add user reports
# opions: user
#
# The script for enabling reports on cron tasks and administrative
# notifications.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -79,8 +79,6 @@ fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
echo "NGINX=$NGINX"
echo "NGINX_EXT=$NGINX_EXT"
# Adding nginx params to config
update_web_domain_value '$NGINX' "$NGINX"

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: backup system user with all its objects
# options: user
#
# The call is used for backing up user with all its domains and databases.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,13 +1,16 @@
#!/bin/bash
# info: updating montly billing user report
# info: backup all users
# options: none
#
# The function backups all system users.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Importing system enviroment as we run this script
# mostly by cron wich not read it by itself
# mostly by cron wich not read it by itself
source /etc/profile.d/vesta.sh
# Importing variables

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: changing user contact email
# info: change user contact email
# options: user email
#
# The function for changing of e-mail associated with a certain user.
#----------------------------------------------------------#
# Variable&Function #
@ -14,6 +18,7 @@ source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: changing user nameservers
# info: change user full name
# options: user fname lname
#
# The function allow to change user's full name.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: changing user nameservers
# info: change user nameservers
# options: user ns1 ns2 [ns3] [ns4] [ns5] [ns6] [ns7] [ns8]
#
# The function for changing default nameservers for speciefic user.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: changing user package
# info: change user package
# options: user package
#
# The function changes user's hosting package.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: changing user password
# info: change user password
# options: user password
#
# The function changes user's password and updates RKEY value.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: changing user shell
# info: change user shell
# options: user shell
#
# The function changes system shell of a user. Shell gives abilty to use ssh.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,10 @@
#!/bin/bash
# info: deliting system user
# info: delete user
# options: user
#
# This function deletes a certain user and all his resourses such as domains,
# databases, cron jobs, etc.
#----------------------------------------------------------#
# Variable&Function #
@ -113,7 +118,7 @@ if [ ! -z "$statp" ]; then
fi
# Removing system user
userdel -f $user
/usr/sbin/userdel -f $user
rm -rf $V_HOME/$user
rm -f /var/spool/mail/$user
rm -f /var/spool/cron/$user

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: deliting system user ips
# info: delete user ips
# options: user
#
# The function deletes all user's ip addresses.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,10 @@
#!/bin/bash
# info: adding user reports
# info: delete user reports
# options: user
#
# The script for disabling reports on cron tasks and administrative
# notifications.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: Getting system user value
# info: get user value
# options: user key
#
# The function for obtaining certain user's parameters.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: listing system user
# info: list system user
# options: user [format]
#
# The function for obtainig the list of all user's parameters.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: listing system bakups
# info: list user backups
# options: user [format]
#
# The function for obtainig the list of available user backups.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: listing user ips
# info: list user ips
# options user [format]
#
# The function for obtainig the list of available ip addresses.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: listing user nameservers
# info: list user nameservers
# options: user [format]
#
# Function for obtainig the list of user's DNS servers.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: listing sys user packages
# info: list user packages
# options: [format]
#
# The function for obtaining the list of available hosting packages.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: listing system users
# info: list system users
# options: [format]
#
# The function for obtainig the list of all server's users.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: Suspending sys user
# info: suspend user
# options: user
#
# The function suspends a certain user and all his objects.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: Unsuspending sys user
# info: unsuspend user
# options: user
#
# The function unsuspends user and all his objects.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: updating current backups for
# info: update user backups
# options: user
#
# The function rescan backup directory and updates backup database.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: updating montly billing user report
# info: update billing user billing
# options: user
#
# Function logs user parameters into billing database.
#----------------------------------------------------------#
# Variable&Function #

View file

@ -1,5 +1,9 @@
#!/bin/bash
# info: updating disk usage for user directories
# info: update user disk usage
# options: user
#
# The functions recalculates disk usage and updates database.
#----------------------------------------------------------#
# Variable&Function #

5
src/c_coding_style.txt Normal file
View file

@ -0,0 +1,5 @@
BASH CODING STYLE
Please see GNU Coding Standards
********************
http://www.gnu.org/prep/standards/standards.txt

View file

@ -9,7 +9,6 @@
/* */
/***************************************************************************/
#define _XOPEN_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@ -21,60 +20,60 @@
int main (int argc, char** argv) {
// defining ip
/* define ip */
char *ip = "127.0.0.1";
// checking argument list
/* check argument list */
if (3 > argc) {
printf("Error: bad args\n",argv[0]);
printf("Usage: %s user password [ip]\n",argv[0]);
exit(1);
};
// checking ip
/* check ip */
if (4 <= argc) {
ip = (char*)malloc(strlen(argv[3]));
strcpy(ip, argv[3]);
}
// formating current time
/* format current time */
time_t lt = time(NULL);
struct tm* ptr = localtime(&lt);
char str[280];
strftime(str, 100, "%Y-%m-%d %H:%M:%S ", ptr);
// openning log file
/* open log file */
FILE* pFile = fopen ("/usr/local/vesta/log/auth.log","a+");
if (NULL == pFile) {
printf("Error: can not open file %s \n", argv[0]);
exit(12);
}
// parsing user argument
/* parse user argument */
struct passwd* userinfo = getpwnam(argv[1]);
if (NULL != userinfo) {
struct spwd* passw = getspnam(userinfo->pw_name);
if (NULL != passw) {
char* cryptedPasswrd = (char*)crypt(argv[2], passw->sp_pwdp);
if (strcmp(passw->sp_pwdp,crypt(argv[2],passw->sp_pwdp))==0) {
// concatinating time with user and ip
/* concatinate time with user and ip */
strcat(str, userinfo->pw_name);
strcat(str, " ");
strcat(str, ip);
strcat(str, " successfully logged in \n");
fputs (str,pFile); // writing
fclose (pFile); // closing
exit(EXIT_SUCCESS); // exiting
fputs (str,pFile); /* write */
fclose (pFile); /* close */
exit(EXIT_SUCCESS); /* exit */
} else {
// concatinating time with user string
/* concatinate time with user string */
printf ("Error: password missmatch\n");
strcat(str, userinfo->pw_name);
strcat(str, " ");
strcat(str, ip);
strcat(str, " failed to login \n");
fputs (str,pFile); // writing
fclose (pFile); // closing
exit(9); // exiting
fputs (str,pFile); /* write */
fclose (pFile); /* close */
exit(9); /* exit */
};
}
} else {

105
test/json.sh Executable file
View file

@ -0,0 +1,105 @@
# https://github.com/dominictarr/JSON.sh
# Code is licensed under the MIT license
# Copyright (c) 2011 Dominic Tarr
throw () {
echo "$*" >&2
exit 1
}
tokenize () {
local ESCAPE='(\\[^u[:cntrl:]]|\\u[0-9a-fA-F]{4})'
local CHAR='[^[:cntrl:]"\\]'
local STRING="\"$CHAR*($ESCAPE$CHAR*)*\""
local NUMBER='-?(0|[1-9][0-9]*)([.][0-9]*)?([eE][+-]?[0-9]*)?'
local KEYWORD='null|false|true'
local SPACE='[[:space:]]+'
egrep -ao "$STRING|$NUMBER|$KEYWORD|$SPACE|." --color=never |
egrep -v "^$SPACE$" # eat whitespace
}
parse_array () {
local index=0
local ary=''
read -r token
case "$token" in
']') ;;
*)
while :
do
parse_value "$1" "$index"
let index=$index+1
ary="$ary""$value"
read -r token
case "$token" in
']') break ;;
',') ary="$ary," ;;
*) throw "EXPECTED , or ] GOT ${token:-EOF}" ;;
esac
read -r token
done
;;
esac
value=`printf '[%s]' $ary`
}
parse_object () {
local key
local obj=''
read -r token
case "$token" in
'}') ;;
*)
while :
do
case "$token" in
'"'*'"') key=$token ;;
*) throw "EXPECTED string GOT ${token:-EOF}" ;;
esac
read -r token
case "$token" in
':') ;;
*) throw "EXPECTED : GOT ${token:-EOF}" ;;
esac
read -r token
parse_value "$1" "$key"
obj="$obj$key:$value"
read -r token
case "$token" in
'}') break ;;
',') obj="$obj," ;;
*) throw "EXPECTED , or } GOT ${token:-EOF}" ;;
esac
read -r token
done
;;
esac
value=`printf '{%s}' "$obj"`
}
parse_value () {
local jpath="${1:+$1,}$2"
case "$token" in
'{') parse_object "$jpath" ;;
'[') parse_array "$jpath" ;;
# At this point, the only valid single-character tokens are digits.
''|[^0-9]) throw "EXPECTED value GOT ${token:-EOF}" ;;
*) value=$token ;;
esac
printf "[%s]\t%s\n" "$jpath" "$value"
}
parse () {
read -r token
parse_value
read -r token
case "$token" in
'') ;;
*) throw "EXPECTED EOF GOT $token" ;;
esac
}
if [ $0 = $BASH_SOURCE ];
then
tokenize | parse
fi

105
test/test_actions.sh Executable file
View file

@ -0,0 +1,105 @@
#!/bin/bash
# Define some variables
source /etc/profile.d/vesta.sh
V_BIN="$VESTA/bin"
V_TEST="$VESTA/test"
# Define functions
tmp_user() {
MATRIX='0123456789'
LENGTH=4
while [ ${n:=1} -le $LENGTH ]; do
rand="$rand${MATRIX:$(($RANDOM%${#MATRIX})):1}"
let n+=1
done
echo "tmp_$rand"
}
echo_result() {
echo -en "$1"
echo -en '\033[60G'
echo -n '['
if [ "$2" -ne 0 ]; then
echo -n 'FAILED'
echo -n ']'
echo -ne '\r\n'
echo "$4"
echo "RETURN VALUE $2"
cat $3
else
echo -n ' OK '
echo -n ']'
fi
echo -ne '\r\n'
}
# Create random username
user=$(tmp_user)
while [ ! -z "$(grep "^$user:" /etc/passwd)" ]; do
user=$(tmp_user)
done
# Create random tmpfile
tmpfile=$(mktemp -p /tmp )
# Add new user
cmd="v_add_user $user $user $user@vestacp.com default Super Test"
$cmd > $tmpfile 2>> $tmpfile
echo_result "Adding new user $user" "$?" "$tmpfile" "$cmd"
# Change system shell
cmd="v_change_user_shell $user bash"
$cmd > $tmpfile 2>> $tmpfile
echo_result "Changing system shell to /bin/bash" "$?" "$tmpfile" "$cmd"
# Change name servers
cmd="v_change_user_ns $user ns0.com ns1.com ns2.com ns3.com"
$cmd > $tmpfile 2>> $tmpfile
echo_result "Changing nameservers" "$?" "$tmpfile" "$cmd"
# Add cron job
cmd="v_add_cron_job $user 1 1 1 1 1 echo"
$cmd > $tmpfile 2>> $tmpfile
echo_result "Adding cron job" "$?" "$tmpfile" "$cmd"
# Suspend cron job
cmd="v_suspend_cron_job $user 1"
$cmd > $tmpfile 2>> $tmpfile
echo_result "Suspending cron job" "$?" "$tmpfile" "$cmd"
# Unsuspend cron job
cmd="v_unsuspend_cron_job $user 1"
$cmd > $tmpfile 2>> $tmpfile
echo_result "Unsuspending cron job" "$?" "$tmpfile" "$cmd"
# Delete cron job
cmd="v_delete_cron_job $user 1"
$cmd > $tmpfile 2>> $tmpfile
echo_result "Deleting cron job" "$?" "$tmpfile" "$cmd"
# Add cron job
cmd="v_add_cron_job $user 1 1 1 1 1 echo 1"
$cmd > $tmpfile 2>> $tmpfile
echo_result "Adding cron job" "$?" "$tmpfile" "$cmd"
# Add cron job
cmd="v_add_cron_job $user 1 1 1 1 1 echo 1"
$cmd > $tmpfile 2>> $tmpfile
if [ "$?" -eq 4 ]; then
retval=0
else
retval=1
fi
echo_result "Dublicate cron job check" "$retval" "$tmpfile" "$cmd"
# Check ip
#cat /proc/net/dev|cut -f 1 -d :|tail -n1
#v_add_sys_ip 192.168.11.11 255.255.255.255 venet0 ekho
# Delete new user
cmd="v_delete_user $user"
$cmd > $tmpfile 2>> $tmpfile
echo_result "Deleting user $user" "$?" "$tmpfile" "$cmd"

54
test/test_json_listing.sh Executable file
View file

@ -0,0 +1,54 @@
#!/bin/bash
source /etc/profile.d/vesta.sh
V_BIN="$VESTA/bin"
V_TEST="$VESTA/test"
commands='v_list_cron_jobs vesta json
v_list_db_bases vesta json
v_list_db_base vesta vesta_read json
v_list_db_host mysql localhost json
v_list_db_hosts mysql json
v_list_dns_domains vesta json
v_list_dns_templates json
v_list_sys_config json
v_list_sys_interfaces json
v_list_sys_ips json
v_list_sys_rrd json
v_list_user vesta json
v_list_user_backups vesta json
v_list_user_ips vesta json
v_list_user_ns vesta json
v_list_user_packages json
v_list_users json
v_list_web_domains vesta json
v_list_web_domain vesta default.vesta.domain json
v_list_web_templates vesta json'
IFS=$'\n'
for cmd in $commands; do
script=$(echo $cmd |cut -f 1 -d ' ')
arg1=$(echo $cmd |cut -f 2 -d ' ')
arg2=$(echo $cmd |cut -f 3 -d ' ')
arg3=$(echo $cmd |cut -f 4 -d ' ')
$V_BIN/$script $arg1 $arg2 $arg3 | $V_TEST/json.sh >/dev/null 2>/dev/null
retval="$?"
echo -en "$cmd"
echo -en '\033[60G'
echo -n '['
if [ "$retval" -ne 0 ]; then
echo -n 'FAILED'
echo -n ']'
echo -ne '\r\n'
$V_BIN/$script $arg1 $arg2 $arg3 | $V_TEST/json.sh
else
echo -n ' OK '
echo -n ']'
fi
echo -ne '\r\n'
done
exit

View file

@ -217,7 +217,7 @@
<div id="batch-processor" class="b-row-selector">
<div class="checkbox-selector cc">
<input class="styled do_action_toggle_batch_selector" autocomplete="off" type="checkbox" value="" />
<span class="selector-title">All</span>
<span class="selector-title">None</span>
</div>
<div class="context-actions c-s-box">
<div class="b-cust-sel complex-select c-s-opt">
@ -226,6 +226,10 @@
<div class="cust-sel-arrow do_action_toggle_custom_select c-s-opt"><i class="do_action_toggle_custom_select">&nbsp;</i></div>
<div class="cust-sel-options complex-select-content c-s-opt hidden">
<div class="cust-sel-option ico_gray c-s-opt do_action_update_cs_value">
<input type="hidden" class="c-s-value" value="Nothing">
Nothing
</div>
<div class="cust-sel-option ico_gray c-s-opt do_action_update_cs_value">
<input type="hidden" class="c-s-value" value="Suspend">
Suspend
</div>

View file

@ -54,6 +54,11 @@ App.Actions.update_cs_value = function(evt)
var val = elm.find('.c-s-value').val();
$('.complex-select-content').addClass('hidden');
if (val.toLowerCase() == 'nothing') {
App.Actions.mass_nothing();
return;
}
if (App.Tmp[App.Env.world + '_selected_records'] > 0) {
var confirm_message_key = App.Tmp[App.Env.world + '_selected_records'] == 1 ? 1 + ' record' : App.Tmp[App.Env.world + '_selected_records'] + ' records';
var confirmed = confirm('This action will ' + val.toLowerCase() + ' ' + confirm_message_key + '. Do you want to proceede?');
@ -83,6 +88,11 @@ App.Actions.mass_unsuspend = function()
App.Actions.reset_batch();
}
App.Actions.mass_nothing = function()
{
$('.complex-select-content').addClass('hidden');
}
App.Actions.mass_action = function(method_name)
{
var rows = $('.checked-row');
@ -561,7 +571,7 @@ App.Actions.add_form_ns = function(evt)
var tpl = App.Templates.get('NS_INPUT', 'user');
tpl.set(':NAME', '');
tpl.set(':NS_LABEL', 'NS');
tpl.set(':NS_LABEL', 'Name Server');
var ref = $(elm).hasClass('form-row') ? elm : $(elm).parents('.form-row');
$(ref).before(tpl.finalize());
@ -571,7 +581,7 @@ App.Actions.add_form_ns = function(evt)
$(form).find('.ns-entry').each(function(i, o)
{
$(o).find('label').text('NS #' + (i + 1));
$(o).find('label').text('Name Server #' + (i + 1));
$(o).find('input').attr('name', 'NS' + (i + 1));
});
}
@ -587,7 +597,7 @@ App.Actions.delete_ns = function(evt)
form = elm.parents('.form:first');
var total_nses = $(form).find('.ns-entry').length;
if (total_nses == App.Settings.NS_MIN) {
return App.Helpers.alert('Minimum number of NS is ' + App.Settings.NS_MIN);
return App.Helpers.alert('Minimum number of Name Servers is ' + App.Settings.NS_MIN);
}
var form = elm.parents('.form:first');
@ -596,7 +606,7 @@ App.Actions.delete_ns = function(evt)
$(form).find('.ns-entry').each(function(i, o)
{
$(o).find('label').text('NS #' + (i + 1));
$(o).find('label').text('Name Server #' + (i + 1));
$(o).find('input').attr('name', 'NS' + (i + 1));
});
}
@ -604,7 +614,7 @@ App.Actions.delete_ns = function(evt)
App.Actions.view_full_ns_list = function(evt)
{
var elm = $(evt.target);
App.Helpers.openInnerPopup(elm, $(elm).parents('.prop-box').find('.ns-full-list:first').html(), 'NS list');
App.Helpers.openInnerPopup(elm, $(elm).parents('.prop-box').find('.ns-full-list:first').html(), 'Name Server list');
}
App.Actions.view_template_info = function(evt)

View file

@ -29,9 +29,11 @@ App.HTML.Build.dns_form = function (options, id) {
if (App.Helpers.isEmpty(options)) {
tpl.set(':title', 'New dns domain');
tpl.set(':save_button', 'ADD');
tpl.set(':DELETE_ACTION', '');
} else {
tpl.set(':title', 'Edit dns domain');
tpl.set(':save_button', 'SAVE');
tpl.set(':DELETE_ACTION', App.Templates.get('DELETE_ACTION', 'general').finalize());
}
tpl.set(':id', id || '');
tpl.set(':DNS_DOMAIN', options.DNS_DOMAIN || '');
@ -55,9 +57,11 @@ App.HTML.Build.ip_form = function (options, id) {
if (App.Helpers.isEmpty(options)) {
tpl.set(':title', 'New ip address');
tpl.set(':save_button', 'ADD');
tpl.set(':DELETE_ACTION', '');
} else {
tpl.set(':title', 'Edit ip address');
tpl.set(':save_button', 'SAVE');
tpl.set(':DELETE_ACTION', App.Templates.get('DELETE_ACTION', 'general').finalize());
}
tpl.set(':id', id || '');
tpl.set(':IP_ADDRESS', options.IP_ADDRESS || '');
@ -84,9 +88,11 @@ App.HTML.Build.user_form = function (options, id) {
if (App.Helpers.isEmpty(options)) {
tpl.set(':title', 'New user');
tpl.set(':save_button', 'ADD');
tpl.set(':DELETE_ACTION', '');
} else {
tpl.set(':title', 'Edit user');
tpl.set(':save_button', 'SAVE');
tpl.set(':DELETE_ACTION', App.Templates.get('DELETE_ACTION', 'general').finalize());
}
options = !App.Helpers.isEmpty(options) ? options : App.Empty.USER;
if (in_edit == true) {
@ -95,7 +101,7 @@ App.HTML.Build.user_form = function (options, id) {
$([3, 4, 5, 6, 7, 8]).each(function (i, index) {
if (options['NS' + index].trim() != '') {
var tpl_ns = App.Templates.get('NS_INPUT', 'user');
tpl_ns.set(':NS_LABEL', 'NS #' + (index));
tpl_ns.set(':NS_LABEL', 'Name Server #' + (index));
tpl_ns.set(':NAME', options['NS' + index]);
ns[ns.length++] = tpl_ns.finalize();
}
@ -135,9 +141,11 @@ App.HTML.Build.web_domain_form = function (options, id) {
if (App.Helpers.isEmpty(options)) {
tpl.set(':title', 'New WEB domain');
tpl.set(':save_button', 'ADD');
tpl.set(':DELETE_ACTION', '');
} else {
tpl.set(':title', 'Edit WEB domain');
tpl.set(':save_button', 'SAVE');
tpl.set(':DELETE_ACTION', App.Templates.get('DELETE_ACTION', 'general').finalize());
}
options = !App.Helpers.isEmpty(options) ? options : App.Empty.WEB_DOMAIN;
if (in_edit == true) {
@ -180,9 +188,11 @@ App.HTML.Build.db_form = function (options, id) {
if (App.Helpers.isEmpty(options)) {
tpl.set(':title', 'New database');
tpl.set(':save_button', 'ADD');
tpl.set(':DELETE_ACTION', '');
} else {
tpl.set(':title', 'Edit database "' + options.DB + '"');
tpl.set(':save_button', 'SAVE');
tpl.set(':DELETE_ACTION', App.Templates.get('DELETE_ACTION', 'general').finalize());
}
options = !App.Helpers.isEmpty(options) ? options : App.Empty.DB;
if (in_edit == true) {
@ -206,9 +216,11 @@ App.HTML.Build.cron_form = function (options, id) {
if (App.Helpers.isEmpty(options)) {
tpl.set(':title', 'New cron job');
tpl.set(':save_button', 'ADD');
tpl.set(':DELETE_ACTION', '');
} else {
tpl.set(':title', 'Edit cron job');
tpl.set(':save_button', 'SAVE');
tpl.set(':DELETE_ACTION', App.Templates.get('DELETE_ACTION', 'general').finalize());
}
options = !App.Helpers.isEmpty(options) ? options : {
DAY: '',

View file

@ -1,10 +1,17 @@
App.Pages.init = function()
{
if ('undefined' == typeof App.Env.initialParams) {
if ('undefined' == typeof App.Env.initialParams) { // first run
App.Ajax.request('MAIN.getInitial', {}, function(reply) {
App.Env.initialParams = reply.data;
App.Helpers.updateInitial();
});
if (!App.Env.initialParams.auth_user.admin) {
var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= App.Helpers.generateUrl('js/user_templates.js?'+Math.random());
head.appendChild(script);
}
});
}
App.Pages.prepareHTML();
@ -18,6 +25,7 @@ App.Pages.init = function()
App.Pages.prepareHTML = function()
{
App.Actions.reset_batch();
$('#actions-toolbar .stats-subbar').remove();
$('#actions-toolbar .do_action_new_entry').removeClass('hidden');
$('.active').removeClass('active');

File diff suppressed because it is too large Load diff

View file

@ -19,6 +19,11 @@ class USER extends AjaxHandler
*/
public function getListExecute(Request $request)
{
if(!VestaSession::getUserRole()){
return self::getUserExecute($request);
}
$reply = array();
$result = Vesta::execute(Vesta::V_LIST_SYS_USERS, array(Config::get('response_type')));
@ -58,7 +63,9 @@ class USER extends AjaxHandler
"U_MAIL_DOMAINS" => $details['U_MAIL_DOMAINS'],
"DATE" => $details['DATE'],
"U_MAIL_FORWARDERS" => '0',
"U_MAIL_BOXES" => '0'
"U_MAIL_BOXES" => '0',
"U_CRON_JOBS" => $details['U_CRON_JOBS'],
"IP_OWNED" => $details['IP_OWNED']
);
$reply[$user] = array_merge($user_details, $nses);
// $reply[$user] = $user_details;
@ -107,6 +114,8 @@ class USER extends AjaxHandler
"U_DNS_DOMAINS" => $details['U_DNS_DOMAINS'],
"U_DATABASES" => $details['U_DATABASES'],
"U_MAIL_DOMAINS" => $details['U_MAIL_DOMAINS'],
"U_CRON_JOBS" => 'todo',
"IP_OWNED" => $details['IP_OWNED'],
"DATE" => $details['DATE']
);
$reply[$user] = $user_details;