-
Notifications
You must be signed in to change notification settings - Fork 0
/
groups-form.php
102 lines (94 loc) · 3.35 KB
/
groups-form.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
<?php
/**
* Contains the form that is used when adding or editing groups.
*
* @package ProjectSend
* @subpackage Groups
*
*/
?>
<script type="text/javascript">
$(document).ready(function() {
$("form").submit(function() {
clean_form(this);
is_complete(this.add_group_form_name,'<?php echo $validation_no_name; ?>');
// show the errors or continue if everything is ok
if (show_form_errors() == false) { return false; }
});
});
</script>
<?php
switch ($groups_form_type) {
case 'new_group':
$submit_value = __('Create group','cftp_admin');
$form_action = 'groups-add.php';
break;
case 'edit_group':
$submit_value = __('Save group','cftp_admin');
$form_action = 'groups-edit.php?id='.$group_id;
break;
}
?>
<form action="<?php echo $form_action; ?>" name="addgroup" method="post">
<ul class="form_fields">
<li>
<label for="add_group_form_name"><?php _e('Group name','cftp_admin'); ?></label>
<input type="text" name="add_group_form_name" id="add_group_form_name" class="required" value="<?php echo (isset($add_group_data_name)) ? stripslashes($add_group_data_name) : ''; ?>" />
</li>
<li>
<label for="add_group_form_description" class="textarea_label"><?php _e('Description','cftp_admin'); ?></label>
<textarea name="add_group_form_description" id="add_group_form_description"><?php echo (isset($add_group_data_description)) ? stripslashes($add_group_data_description) : ''; ?></textarea>
</li>
<li class="assigns">
<label for="add_group_form_members"><?php _e('Members','cftp_admin'); ?></label>
<select multiple="multiple" id="members-select" class="form-control chosen-select" name="add_group_form_members[]" data-placeholder="<?php _e('Select one or more options. Type to search.', 'cftp_admin');?>">
<?php
$sql = $database->query("SELECT * FROM tbl_users WHERE level = '0' ORDER BY name ASC");
while($row = mysql_fetch_array($sql)) {
?>
<option value="<?php echo $row["id"]; ?>"
<?php
if($groups_form_type == 'edit_group') {
if (in_array($row["id"],$current_members)) {
echo ' selected="selected"';
}
}
?>
><?php echo $row["name"]; ?></option>
<?php
}
?>
</select>
<div class="list_mass_members">
<a href="#" class="btn add-all"><?php _e('Add all','cftp_admin'); ?></a>
<a href="#" class="btn remove-all"><?php _e('Remove all','cftp_admin'); ?></a>
</div>
</li>
</ul>
<div class="inside_form_buttons">
<button type="submit" name="submit" class="btn btn-wide btn-primary"><?php echo $submit_value; ?></button>
</div>
</form>
<script type="text/javascript">
$(document).ready(function() {
$('.chosen-select').chosen({
no_results_text: "<?php _e('No results where found.','cftp_admin'); ?>",
});
$('.add-all').click(function(){
var selector = $(this).closest('.assigns').find('select');
$(selector).find('option').each(function(){
$(this).prop('selected', true);
});
$('select').trigger('chosen:updated');
return false;
});
$('.remove-all').click(function(){
var selector = $(this).closest('.assigns').find('select');
$(selector).find('option').each(function(){
$(this).prop('selected', false);
});
$('select').trigger('chosen:updated');
return false;
});
});
</script>