-
Notifications
You must be signed in to change notification settings - Fork 0
/
groups-add.php
105 lines (88 loc) · 2.58 KB
/
groups-add.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
* Show the form to add a new group.
*
* @package ProjectSend
* @subpackage Groups
*
*/
$multiselect = 1;
$allowed_levels = array(9,8);
require_once('sys.includes.php');
$active_nav = 'groups';
$page_title = __('Add clients group','cftp_admin');
include('header.php');
$database->MySQLDB();
if ($_POST) {
$new_group = new GroupActions();
/**
* Clean the posted form values to be used on the groups actions,
* and again on the form if validation failed.
*/
$add_group_data_name = encode_html($_POST['add_group_form_name']);
$add_group_data_description = encode_html($_POST['add_group_form_description']);
$add_group_data_members = $_POST['add_group_form_members'];
/** Arguments used on validation and group creation. */
$new_arguments = array(
'id' => '',
'name' => $add_group_data_name,
'description' => $add_group_data_description,
'members' => $add_group_data_members
);
/** Validate the information from the posted form. */
$new_validate = $new_group->validate_group($new_arguments);
/** Create the group if validation is correct. */
if ($new_validate == 1) {
$new_response = $new_group->create_group($new_arguments);
}
}
?>
<div id="main">
<h2><?php echo $page_title; ?></h2>
<div class="whiteform whitebox">
<?php
/**
* If the form was submited with errors, show them here.
*/
$valid_me->list_errors();
?>
<?php
if (isset($new_response)) {
/**
* Get the process state and show the corresponding ok or error messages.
*/
switch ($new_response['query']) {
case 1:
$msg = __('Group added correctly.','cftp_admin');
echo system_message('ok',$msg);
/** Record the action log */
$new_log_action = new LogActions();
$log_action_args = array(
'action' => 23,
'owner_id' => $global_id,
'affected_account' => $new_response['new_id'],
'affected_account_name' => $add_group_data_name
);
$new_record_action = $new_log_action->log_action_save($log_action_args);
break;
case 0:
$msg = __('There was an error. Please try again.','cftp_admin');
echo system_message('error',$msg);
break;
}
}
else {
/**
* If not $new_response is set, it means we are just entering for the first time.
* Include the form.
*/
$groups_form_type = 'new_group';
include('groups-form.php');
}
?>
</div>
</div>
<?php
$database->Close();
include('footer.php');
?>