-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathcustomergroup.php
105 lines (97 loc) · 3.34 KB
/
customergroup.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
/*
* LMS version 1.11-git
*
* (C) Copyright 2001-2012 LMS Developers
*
* Please, see the doc/AUTHORS for more information about authors!
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id$
*/
$action = isset($_GET['action']) ? $_GET['action'] : '';
if($action == 'delete')
{
$LMS->CustomerAssignmentDelete(
array('customerid' => intval($_GET['id']),
'customergroupid' => $_GET['customergroupid']));
}
elseif($action == 'add')
{
$groupid = intval($_POST['customergroupid']);
$uid = intval($_GET['id']);
if ($LMS->CustomerGroupExists($groupid)
&& !$LMS->CustomerassignmentExist($groupid, $uid)
&& $LMS->CustomerExists($uid))
{
$LMS->CustomerAssignmentAdd(
array('customerid' => $uid, 'customergroupid' => $groupid));
}
}
elseif(!empty($_POST['setwarnings']))
{
$setwarnings = $_POST['setwarnings'];
$oper = isset($_GET['oper']) ? $_GET['oper'] : '';
$groupid = isset($setwarnings['customergroup']) ? $setwarnings['customergroup'] : 0;
if ($oper != '' && $groupid != 0)
{
$customerassignmentdata['customergroupid'] = $groupid;
foreach($setwarnings['mcustomerid'] as $uid)
{
$customerassignmentdata['customerid'] = $uid;
switch ($oper)
{
case 'addtogroup':
if (!$LMS->CustomerassignmentExist($groupid, $uid))
$LMS->CustomerassignmentAdd($customerassignmentdata);
break;
case 'removefromgroup':
$LMS->CustomerassignmentDelete($customerassignmentdata);
break;
}
}
}
}
elseif(!empty($_POST['customerassignments']) && $LMS->CustomerGroupExists($_GET['id']))
{
$oper = $_POST['oper'];
$customerassignments = $_POST['customerassignments'];
if(isset($customerassignments['gmcustomerid']) && $oper=='0')
{
$assignment['customergroupid'] = $_GET['id'];
foreach($customerassignments['gmcustomerid'] as $value)
{
$assignment['customerid'] = $value;
$LMS->CustomerassignmentDelete($assignment);
}
}
elseif (isset($customerassignments['mcustomerid']) && $oper=='1')
{
$assignment['customergroupid'] = $_GET['id'];
foreach($customerassignments['mcustomerid'] as $value)
{
$assignment['customerid'] = $value;
if(! $LMS->CustomerassignmentExist($assignment['customergroupid'],$value))
$LMS->CustomerassignmentAdd($assignment);
}
}
elseif ($oper=='2' || $oper=='3')
$SESSION->redirect('?'.preg_replace('/&[a-z]*id=[0-9]+/i', '', $SESSION->get('backto')).'&id='.$_GET['id']
.(isset($customerassignments['membersnetid']) && $customerassignments['membersnetid'] != '0' ? '&membersnetid='.$customerassignments['membersnetid'] : '')
.(isset($customerassignments['othersnetid']) && $customerassignments['othersnetid'] != '0' ? '&othersnetid='.$customerassignments['othersnetid'] : ''));
}
$SESSION->redirect('?'.$SESSION->get('backto'));
?>