forked from concretecms/concrete5-legacy
/
group_sets.php
58 lines (52 loc) · 1.7 KB
/
group_sets.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
<?php
defined('C5_EXECUTE') or die("Access Denied.");
class DashboardUsersGroupSetsController extends Concrete5_Controller_Dashboard_Users_Group_Sets {
public function add_set() {
if ($this->token->validate('add_set')) {
if (!trim($this->post('gsName'))) {
$this->error->add(t("Specify a name for your group set."));
}
$gsName = trim($this->post('gsName'));
if (!Loader::helper('validation/strings')->multiLingualName($gsName, true)) {
$this->error->add(t('Set Names must only include alphanumerics and spaces.'));
}
if (!$this->error->has()) {
$gs = GroupSet::add($gsName);
if (is_array($_POST['gID'])) {
foreach($_POST['gID'] as $gID) {
$g = Group::getByID($gID);
if(is_object($g)) {
$gs->addGroup($g);
}
}
}
$this->redirect('dashboard/users/group_sets', 'set_added');
}
} else {
$this->error->add($this->token->getErrorMessage());
}
}
public function update_set() {
$this->edit($this->post('gsID'));
if ($this->token->validate('update_set')) {
$as = GroupSet::getByID($this->post('gsID'));
if (!is_object($as)) {
$this->error->add(t('Invalid group set.'));
} else {
if (!trim($this->post('gsName'))) {
$this->error->add(t("Specify a name for your group set."));
}
}
$gsName = trim($this->post('gsName'));
if (!Loader::helper('validation/strings')->multiLingualName($gsName, true)) {
$this->error->add(t('Set Names must only include alphanumerics and spaces.'));
}
if (!$this->error->has()) {
$as->updateGroupSetName($gsName);
$this->redirect('dashboard/users/group_sets', 'set_updated');
}
} else {
$this->error->add($this->token->getErrorMessage());
}
}
}