Skip to content

Commit b17cc67

Browse files
committed
- Added group (we call groups "circles" so that users don't mix them up with user groups) feature to client messaging section so that messages can be sent to either all clients/resellers or to groups of clients/resellers. TODO: add circle access control so that 1) a reseller can create circles that contain only his clients, not all clients, and 2) a reseller can send messages only to his own circles instead of all circles.
1 parent 98ad85e commit b17cc67

20 files changed

+587
-11
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CREATE TABLE IF NOT EXISTS `client_circle` (
2+
`circle_id` int(11) NOT NULL AUTO_INCREMENT,
3+
`sys_userid` int(11) NOT NULL DEFAULT '0',
4+
`sys_groupid` int(11) NOT NULL DEFAULT '0',
5+
`sys_perm_user` varchar(5) DEFAULT NULL,
6+
`sys_perm_group` varchar(5) DEFAULT NULL,
7+
`sys_perm_other` varchar(5) DEFAULT NULL,
8+
`circle_name` varchar(64) DEFAULT NULL,
9+
`client_ids` text,
10+
`description` text,
11+
`active` enum('n','y') NOT NULL default 'y',
12+
PRIMARY KEY (`circle_id`)
13+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

install/sql/ispconfig3.sql

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,26 @@ CREATE TABLE `client` (
152152

153153
-- --------------------------------------------------------
154154

155+
--
156+
-- Table structure for table `client_circle`
157+
--
158+
159+
CREATE TABLE `client_circle` (
160+
`circle_id` int(11) NOT NULL AUTO_INCREMENT,
161+
`sys_userid` int(11) NOT NULL DEFAULT '0',
162+
`sys_groupid` int(11) NOT NULL DEFAULT '0',
163+
`sys_perm_user` varchar(5) DEFAULT NULL,
164+
`sys_perm_group` varchar(5) DEFAULT NULL,
165+
`sys_perm_other` varchar(5) DEFAULT NULL,
166+
`circle_name` varchar(64) DEFAULT NULL,
167+
`client_ids` text,
168+
`description` text,
169+
`active` enum('n','y') NOT NULL default 'y',
170+
PRIMARY KEY (`circle_id`)
171+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
172+
173+
-- --------------------------------------------------------
174+
155175
--
156176
-- Table structure for table `client_template`
157177
--
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
/******************************************
32+
* Begin Form configuration
33+
******************************************/
34+
35+
$list_def_file = "list/client_circle.list.php";
36+
$tform_def_file = "form/client_circle.tform.php";
37+
38+
/******************************************
39+
* End Form configuration
40+
******************************************/
41+
42+
require_once('../../lib/config.inc.php');
43+
require_once('../../lib/app.inc.php');
44+
45+
//* Check permissions for module
46+
$app->auth->check_module_permissions('client');
47+
if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mode.');
48+
49+
$app->uses('tpl,tform');
50+
$app->load('tform_actions');
51+
52+
class page_action extends tform_actions {
53+
54+
}
55+
56+
$page = new page_action;
57+
$page->onDelete()
58+
59+
?>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/*
3+
Copyright (c) 2005 - 2012, Till Brehm, projektfarm Gmbh, ISPConfig UG
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without modification,
7+
are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice,
10+
this list of conditions and the following disclaimer.
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
* Neither the name of ISPConfig nor the names of its contributors
15+
may be used to endorse or promote products derived from this software without
16+
specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
31+
/******************************************
32+
* Begin Form configuration
33+
******************************************/
34+
35+
$tform_def_file = "form/client_circle.tform.php";
36+
37+
/******************************************
38+
* End Form configuration
39+
******************************************/
40+
41+
require_once('../../lib/config.inc.php');
42+
require_once('../../lib/app.inc.php');
43+
require_once('tools.inc.php');
44+
45+
//* Check permissions for module
46+
$app->auth->check_module_permissions('client');
47+
48+
// Loading classes
49+
$app->uses('tpl,tform,tform_actions');
50+
$app->load('tform_actions');
51+
52+
class page_action extends tform_actions {
53+
54+
}
55+
56+
$page = new page_action;
57+
$page->onLoad();
58+
59+
?>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
require_once('../../lib/config.inc.php');
3+
require_once('../../lib/app.inc.php');
4+
5+
/******************************************
6+
* Begin Form configuration
7+
******************************************/
8+
9+
$list_def_file = "list/client_circle.list.php";
10+
11+
/******************************************
12+
* End Form configuration
13+
******************************************/
14+
15+
//* Check permissions for module
16+
$app->auth->check_module_permissions('client');
17+
18+
$app->uses('listform_actions');
19+
20+
$app->listform_actions->SQLOrderBy = 'ORDER BY circle_name, circle_id';
21+
$app->listform_actions->onLoad();
22+
23+
24+
?>

interface/web/client/client_message.php

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,35 @@
5959

6060
//* Send message
6161
if($error == '') {
62-
//* Select all clients and resellers
63-
if($_SESSION["s"]["user"]["typ"] == 'admin'){
64-
$sql = "SELECT * FROM client WHERE email != ''";
62+
if(intval($_POST['recipient']) > 0){
63+
$circle = $app->db->queryOneRecord("SELECT client_ids FROM client_circle WHERE active = 'y' AND circle_id = ".intval($_POST['recipient']));
64+
if(isset($circle['client_ids']) && $circle['client_ids'] != ''){
65+
$tmp_client_ids = explode(',',$circle['client_ids']);
66+
$where = array();
67+
foreach($tmp_client_ids as $tmp_client_id){
68+
$where[] = 'client_id = '.$tmp_client_id;
69+
}
70+
if(!empty($where)) $where_clause = ' AND ('.implode(' OR ', $where).')';
71+
$sql = "SELECT * FROM client WHERE email != ''".$where_clause;
72+
} else {
73+
$sql = "SELECT * FROM client WHERE 0";
74+
}
6575
} else {
66-
$client_id = intval($_SESSION['s']['user']['client_id']);
67-
if($client_id == 0) die('Invalid Client ID.');
68-
$sql = "SELECT * FROM client WHERE email != '' AND parent_client_id = '$client_id'";
76+
//* Select all clients and resellers
77+
if($_SESSION["s"]["user"]["typ"] == 'admin'){
78+
$sql = "SELECT * FROM client WHERE email != ''";
79+
} else {
80+
$client_id = intval($_SESSION['s']['user']['client_id']);
81+
if($client_id == 0) die('Invalid Client ID.');
82+
$sql = "SELECT * FROM client WHERE email != '' AND parent_client_id = '$client_id'";
83+
}
6984
}
7085

7186
//* Get clients
7287
$clients = $app->db->queryAllRecords($sql);
7388
if(is_array($clients)) {
7489
$msg = $wb['email_sent_to_txt'].' ';
7590
foreach($clients as $client) {
76-
7791
//* Parse cleint details into message
7892
$message = $_POST['message'];
7993
foreach($client as $key => $val) {
@@ -94,6 +108,17 @@
94108
}
95109
}
96110

111+
// Recipient Drop-Down
112+
$recipient = '<option value="0">'.$wb['all_clients_resellers_txt'].'</option>';
113+
$sql = "SELECT * FROM client_circle WHERE active = 'y'";
114+
$circles = $app->db->queryAllRecords($sql);
115+
if(is_array($circles) && !empty($circles)){
116+
foreach($circles as $circle){
117+
$recipient .= '<option value="'.$circle['circle_id'].'">'.$circle['circle_name'].'</option>';
118+
}
119+
}
120+
$app->tpl->setVar('recipient',$recipient);
121+
97122
if($_SESSION["s"]["user"]["typ"] == 'admin'){
98123
$app->tpl->setVar('form_legend_txt',$wb['form_legend_admin_txt']);
99124
} else {
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
<?php
2+
3+
/*
4+
Form Definition
5+
6+
Tabledefinition
7+
8+
Datatypes:
9+
- INTEGER (Forces the input to Int)
10+
- DOUBLE
11+
- CURRENCY (Formats the values to currency notation)
12+
- VARCHAR (no format check, maxlength: 255)
13+
- TEXT (no format check)
14+
- DATE (Dateformat, automatic conversion to timestamps)
15+
16+
Formtype:
17+
- TEXT (Textfield)
18+
- TEXTAREA (Textarea)
19+
- PASSWORD (Password textfield, input is not shown when edited)
20+
- SELECT (Select option field)
21+
- RADIO
22+
- CHECKBOX
23+
- CHECKBOXARRAY
24+
- FILE
25+
26+
VALUE:
27+
- Wert oder Array
28+
29+
Hint:
30+
The ID field of the database table is not part of the datafield definition.
31+
The ID field must be always auto incement (int or bigint).
32+
33+
Search:
34+
- searchable = 1 or searchable = 2 include the field in the search
35+
- searchable = 1: this field will be the title of the search result
36+
- searchable = 2: this field will be included in the description of the search result
37+
38+
39+
*/
40+
41+
$form["title"] = "Client Circle";
42+
$form["description"] = "";
43+
$form["name"] = "client_circle";
44+
$form["action"] = "client_circle_edit.php";
45+
$form["db_table"] = "client_circle";
46+
$form["db_table_idx"] = "circle_id";
47+
$form["db_history"] = "yes";
48+
$form["tab_default"] = "circle";
49+
$form["list_default"] = "client_circle_list.php";
50+
$form["auth"] = 'yes';
51+
52+
$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
53+
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
54+
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
55+
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
56+
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
57+
58+
//* Languages
59+
$language_list = array();
60+
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
61+
while ($file = @readdir ($handle)) {
62+
if ($file != '.' && $file != '..') {
63+
if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
64+
$tmp = substr($file, 0, 2);
65+
$language_list[$tmp] = $tmp;
66+
}
67+
}
68+
}
69+
70+
//* Load themes
71+
$themes_list = array();
72+
$handle = @opendir(ISPC_THEMES_PATH);
73+
while ($file = @readdir ($handle)) {
74+
if (substr($file, 0, 1) != '.') {
75+
if(@is_dir(ISPC_THEMES_PATH."/$file")) {
76+
$themes_list[$file] = $file;
77+
}
78+
}
79+
}
80+
81+
$form["tabs"]['circle'] = array (
82+
'title' => "Circle",
83+
'width' => 100,
84+
'template' => "templates/client_circle_edit.htm",
85+
'fields' => array (
86+
##################################
87+
# Begin Datatable fields
88+
##################################
89+
'circle_name' => array (
90+
'datatype' => 'VARCHAR',
91+
'formtype' => 'TEXT',
92+
'default' => '',
93+
'value' => '',
94+
'separator' => '',
95+
'width' => '30',
96+
'maxlength' => '255',
97+
'rows' => '',
98+
'cols' => '',
99+
'searchable' => 2
100+
),
101+
'client_ids' => array (
102+
'datatype' => 'VARCHAR',
103+
'formtype' => 'CHECKBOXARRAY',
104+
'default' => '',
105+
'separator' => ',',
106+
'datasource' => array ( 'type' => 'SQL',
107+
'querystring' => 'SELECT client_id,contact_name FROM client WHERE 1 ORDER BY contact_name',
108+
'keyfield'=> 'client_id',
109+
'valuefield'=> 'contact_name'
110+
),
111+
'value' => ''
112+
),
113+
'description' => array (
114+
'datatype' => 'TEXT',
115+
'formtype' => 'TEXTAREA',
116+
'default' => '',
117+
'value' => '',
118+
'separator' => '',
119+
'width' => '',
120+
'maxlength' => '',
121+
'rows' => '10',
122+
'cols' => '30'
123+
),
124+
'active' => array (
125+
'datatype' => 'VARCHAR',
126+
'formtype' => 'CHECKBOX',
127+
'default' => 'y',
128+
'value' => array(0 => 'n',1 => 'y')
129+
),
130+
##################################
131+
# END Datatable fields
132+
##################################
133+
)
134+
);
135+
136+
137+
?>

interface/web/client/lib/lang/de.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ $wb['add_additional_template_txt'] = 'Zusätzliches Template hinzufügen';
1414
$wb['delete_additional_template_txt'] = 'Zusätzliches Template löschen';
1515
$wb['Messaging'] = 'Benachrichtigungen';
1616
$wb['Send email'] = 'E-Mail versenden';
17+
$wb['Edit Client Circle'] = 'Kundenkreis bearbeiten';
1718
?>

0 commit comments

Comments
 (0)