Commit b17cc67e authored by Falko Timme's avatar Falko Timme

- Added group (we call groups "circles" so that users don't mix them up with...

- 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.
parent 98ad85ef
CREATE TABLE IF NOT EXISTS `client_circle` (
`circle_id` int(11) NOT NULL AUTO_INCREMENT,
`sys_userid` int(11) NOT NULL DEFAULT '0',
`sys_groupid` int(11) NOT NULL DEFAULT '0',
`sys_perm_user` varchar(5) DEFAULT NULL,
`sys_perm_group` varchar(5) DEFAULT NULL,
`sys_perm_other` varchar(5) DEFAULT NULL,
`circle_name` varchar(64) DEFAULT NULL,
`client_ids` text,
`description` text,
`active` enum('n','y') NOT NULL default 'y',
PRIMARY KEY (`circle_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
\ No newline at end of file
......@@ -152,6 +152,26 @@ CREATE TABLE `client` (
-- --------------------------------------------------------
--
-- Table structure for table `client_circle`
--
CREATE TABLE `client_circle` (
`circle_id` int(11) NOT NULL AUTO_INCREMENT,
`sys_userid` int(11) NOT NULL DEFAULT '0',
`sys_groupid` int(11) NOT NULL DEFAULT '0',
`sys_perm_user` varchar(5) DEFAULT NULL,
`sys_perm_group` varchar(5) DEFAULT NULL,
`sys_perm_other` varchar(5) DEFAULT NULL,
`circle_name` varchar(64) DEFAULT NULL,
`client_ids` text,
`description` text,
`active` enum('n','y') NOT NULL default 'y',
PRIMARY KEY (`circle_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `client_template`
--
......
<?php
/*
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/client_circle.list.php";
$tform_def_file = "form/client_circle.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Check permissions for module
$app->auth->check_module_permissions('client');
if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mode.');
$app->uses('tpl,tform');
$app->load('tform_actions');
class page_action extends tform_actions {
}
$page = new page_action;
$page->onDelete()
?>
<?php
/*
Copyright (c) 2005 - 2012, Till Brehm, projektfarm Gmbh, ISPConfig UG
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/******************************************
* Begin Form configuration
******************************************/
$tform_def_file = "form/client_circle.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
require_once('tools.inc.php');
//* Check permissions for module
$app->auth->check_module_permissions('client');
// Loading classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
class page_action extends tform_actions {
}
$page = new page_action;
$page->onLoad();
?>
<?php
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/client_circle.list.php";
/******************************************
* End Form configuration
******************************************/
//* Check permissions for module
$app->auth->check_module_permissions('client');
$app->uses('listform_actions');
$app->listform_actions->SQLOrderBy = 'ORDER BY circle_name, circle_id';
$app->listform_actions->onLoad();
?>
\ No newline at end of file
......@@ -59,13 +59,28 @@ if(isset($_POST) && count($_POST) > 1) {
//* Send message
if($error == '') {
//* Select all clients and resellers
if($_SESSION["s"]["user"]["typ"] == 'admin'){
$sql = "SELECT * FROM client WHERE email != ''";
if(intval($_POST['recipient']) > 0){
$circle = $app->db->queryOneRecord("SELECT client_ids FROM client_circle WHERE active = 'y' AND circle_id = ".intval($_POST['recipient']));
if(isset($circle['client_ids']) && $circle['client_ids'] != ''){
$tmp_client_ids = explode(',',$circle['client_ids']);
$where = array();
foreach($tmp_client_ids as $tmp_client_id){
$where[] = 'client_id = '.$tmp_client_id;
}
if(!empty($where)) $where_clause = ' AND ('.implode(' OR ', $where).')';
$sql = "SELECT * FROM client WHERE email != ''".$where_clause;
} else {
$sql = "SELECT * FROM client WHERE 0";
}
} else {
$client_id = intval($_SESSION['s']['user']['client_id']);
if($client_id == 0) die('Invalid Client ID.');
$sql = "SELECT * FROM client WHERE email != '' AND parent_client_id = '$client_id'";
//* Select all clients and resellers
if($_SESSION["s"]["user"]["typ"] == 'admin'){
$sql = "SELECT * FROM client WHERE email != ''";
} else {
$client_id = intval($_SESSION['s']['user']['client_id']);
if($client_id == 0) die('Invalid Client ID.');
$sql = "SELECT * FROM client WHERE email != '' AND parent_client_id = '$client_id'";
}
}
//* Get clients
......@@ -73,7 +88,6 @@ if(isset($_POST) && count($_POST) > 1) {
if(is_array($clients)) {
$msg = $wb['email_sent_to_txt'].' ';
foreach($clients as $client) {
//* Parse cleint details into message
$message = $_POST['message'];
foreach($client as $key => $val) {
......@@ -94,6 +108,17 @@ if(isset($_POST) && count($_POST) > 1) {
}
}
// Recipient Drop-Down
$recipient = '<option value="0">'.$wb['all_clients_resellers_txt'].'</option>';
$sql = "SELECT * FROM client_circle WHERE active = 'y'";
$circles = $app->db->queryAllRecords($sql);
if(is_array($circles) && !empty($circles)){
foreach($circles as $circle){
$recipient .= '<option value="'.$circle['circle_id'].'">'.$circle['circle_name'].'</option>';
}
}
$app->tpl->setVar('recipient',$recipient);
if($_SESSION["s"]["user"]["typ"] == 'admin'){
$app->tpl->setVar('form_legend_txt',$wb['form_legend_admin_txt']);
} else {
......
<?php
/*
Form Definition
Tabledefinition
Datatypes:
- INTEGER (Forces the input to Int)
- DOUBLE
- CURRENCY (Formats the values to currency notation)
- VARCHAR (no format check, maxlength: 255)
- TEXT (no format check)
- DATE (Dateformat, automatic conversion to timestamps)
Formtype:
- TEXT (Textfield)
- TEXTAREA (Textarea)
- PASSWORD (Password textfield, input is not shown when edited)
- SELECT (Select option field)
- RADIO
- CHECKBOX
- CHECKBOXARRAY
- FILE
VALUE:
- Wert oder Array
Hint:
The ID field of the database table is not part of the datafield definition.
The ID field must be always auto incement (int or bigint).
Search:
- searchable = 1 or searchable = 2 include the field in the search
- searchable = 1: this field will be the title of the search result
- searchable = 2: this field will be included in the description of the search result
*/
$form["title"] = "Client Circle";
$form["description"] = "";
$form["name"] = "client_circle";
$form["action"] = "client_circle_edit.php";
$form["db_table"] = "client_circle";
$form["db_table_idx"] = "circle_id";
$form["db_history"] = "yes";
$form["tab_default"] = "circle";
$form["list_default"] = "client_circle_list.php";
$form["auth"] = 'yes';
$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
if ($file != '.' && $file != '..') {
if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
$tmp = substr($file, 0, 2);
$language_list[$tmp] = $tmp;
}
}
}
//* Load themes
$themes_list = array();
$handle = @opendir(ISPC_THEMES_PATH);
while ($file = @readdir ($handle)) {
if (substr($file, 0, 1) != '.') {
if(@is_dir(ISPC_THEMES_PATH."/$file")) {
$themes_list[$file] = $file;
}
}
}
$form["tabs"]['circle'] = array (
'title' => "Circle",
'width' => 100,
'template' => "templates/client_circle_edit.htm",
'fields' => array (
##################################
# Begin Datatable fields
##################################
'circle_name' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'separator' => '',
'width' => '30',
'maxlength' => '255',
'rows' => '',
'cols' => '',
'searchable' => 2
),
'client_ids' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOXARRAY',
'default' => '',
'separator' => ',',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT client_id,contact_name FROM client WHERE 1 ORDER BY contact_name',
'keyfield'=> 'client_id',
'valuefield'=> 'contact_name'
),
'value' => ''
),
'description' => array (
'datatype' => 'TEXT',
'formtype' => 'TEXTAREA',
'default' => '',
'value' => '',
'separator' => '',
'width' => '',
'maxlength' => '',
'rows' => '10',
'cols' => '30'
),
'active' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'y',
'value' => array(0 => 'n',1 => 'y')
),
##################################
# END Datatable fields
##################################
)
);
?>
......@@ -14,4 +14,5 @@ $wb['add_additional_template_txt'] = 'Zusätzliches Template hinzufügen';
$wb['delete_additional_template_txt'] = 'Zusätzliches Template löschen';
$wb['Messaging'] = 'Benachrichtigungen';
$wb['Send email'] = 'E-Mail versenden';
$wb['Edit Client Circle'] = 'Kundenkreis bearbeiten';
?>
<?php
$wb["Client Circle"] = 'Kundenkreis';
$wb["Circle"] = 'Kreis';
$wb["circle_txt"] = 'Kreis';
$wb["circle_name_txt"] = 'Kreisname';
$wb["client_ids_txt"] = 'Kunden/Reseller';
$wb["description_txt"] = 'Beschreibung';
$wb["active_txt"] = 'Aktiv';
?>
\ No newline at end of file
<?php
$wb["list_head_txt"] = 'Kundenkreise';
$wb["circle_id_txt"] = 'Kreis-ID';
$wb["circle_name_txt"] = 'Kreisname';
$wb["description_txt"] = 'Beschreibung';
$wb["add_new_record_txt"] = 'Kreis hinzufügen';
$wb["filter_txt"] = 'Filter';
$wb["delete_txt"] = 'Löschen';
$wb["active_txt"] = 'Aktiv';
?>
\ No newline at end of file
......@@ -4,10 +4,12 @@ $wb["btn_cancel_txt"] = 'Abbrechen';
$wb["sender_txt"] = 'Absender-E-Mail-Adresse';
$wb["subject_txt"] = 'Betreff';
$wb["message_txt"] = 'Nachricht';
$wb["form_legend_client_txt"] = 'E-Mail-Nachricht an alle Kunden versenden.';
$wb["form_legend_admin_txt"] = 'E-Mail-Nachricht an alle Kunden und Reseller versenden.';
$wb["form_legend_client_txt"] = 'E-Mail-Nachricht an Kunden versenden.';
$wb["form_legend_admin_txt"] = 'E-Mail-Nachricht an Kunden und Reseller versenden.';
$wb["sender_invalid_error"] = 'Absender-E-Mail-Adresse ist ungültig.';
$wb["subject_invalid_error"] = 'Betreff ist leer.';
$wb["message_invalid_error"] = 'Nachricht ist leer.';
$wb["email_sent_to_txt"] = 'E-Mail verschickt an:';
$wb["recipient_txt"] = 'Empfänger';
$wb["all_clients_resellers_txt"] = 'Alle Kunden und Reseller';
?>
......@@ -14,4 +14,5 @@ $wb['add_additional_template_txt'] = 'Add additional template';
$wb['delete_additional_template_txt'] = 'Delete additional template';
$wb['Messaging'] = 'Messaging';
$wb['Send email'] = 'Send Email';
$wb['Edit Client Circle'] = 'Edit Client Circle';
?>
\ No newline at end of file
<?php
$wb["Client Circle"] = 'Client Circle';
$wb["Circle"] = 'Circle';
$wb["circle_txt"] = 'Circle';
$wb["circle_name_txt"] = 'Circle Name';
$wb["client_ids_txt"] = 'Clients/Resellers';
$wb["description_txt"] = 'Description';
$wb["active_txt"] = 'Active';
?>
\ No newline at end of file
<?php
$wb["list_head_txt"] = 'Client Circles';
$wb["circle_id_txt"] = 'Circle ID';
$wb["circle_name_txt"] = 'Circle Name';
$wb["description_txt"] = 'Description';
$wb["add_new_record_txt"] = 'Add new circle';
$wb["filter_txt"] = 'Filter';
$wb["delete_txt"] = 'Delete';
$wb["active_txt"] = 'Active';
?>
\ No newline at end of file
......@@ -4,10 +4,12 @@ $wb["btn_cancel_txt"] = 'Cancel';
$wb["sender_txt"] = 'Sender email address';
$wb["subject_txt"] = 'Subject';
$wb["message_txt"] = 'Message';
$wb["form_legend_client_txt"] = 'Send email message to all clients.';
$wb["form_legend_admin_txt"] = 'Send email message to all clients and resellers.';
$wb["form_legend_client_txt"] = 'Send email message to clients.';
$wb["form_legend_admin_txt"] = 'Send email message to clients and resellers.';
$wb["sender_invalid_error"] = 'Sender email invalid.';
$wb["subject_invalid_error"] = 'Subject is empty.';
$wb["message_invalid_error"] = 'Message is empty.';
$wb["email_sent_to_txt"] = 'Email sent to:';
$wb["recipient_txt"] = 'Recipient';
$wb["all_clients_resellers_txt"] = 'All clients and resellers';
?>
......@@ -56,6 +56,11 @@ $module["nav"][] = array( 'title' => 'Resellers',
unset($items);
}
$items[] = array( 'title' => "Edit Client Circle",
'target' => 'content',
'link' => 'client/client_circle_list.php',
'html_id' => 'client_circle_list');
$items[] = array( 'title' => "Send email",
'target' => 'content',
'link' => 'client/client_message.php',
......
<?php
/*
Datatypes:
- INTEGER
- DOUBLE
- CURRENCY
- VARCHAR
- TEXT
- DATE
*/
// Name of the list
$liste["name"] = "client_circle";
// Database table
$liste["table"] = "client_circle";
// Index index field of the database table
$liste["table_idx"] = "circle_id";
// Search Field Prefix
$liste["search_prefix"] = "search_";
// Records per page
$liste["records_per_page"] = "15";
// Script File of the list
$liste["file"] = "client_circle_list.php";
// Script file of the edit form
$liste["edit_file"] = "client_circle_edit.php";
// Script File of the delete script
$liste["delete_file"] = "client_circle_del.php";
// Paging Template
$liste["paging_tpl"] = "templates/paging.tpl.htm";
// Enable authe
$liste["auth"] = "yes";
/*****************************************************
* Suchfelder
*****************************************************/
$liste["item"][] = array( 'field' => "circle_id",
'datatype' => "INTEGER",
'formtype' => "TEXT",
'op' => "=",
'prefix' => "",
'suffix' => "",
'width' => "",
'value' => "");
$liste["item"][] = array( 'field' => "active",
'datatype' => "VARCHAR",
'formtype' => "SELECT",
'op' => "=",
'prefix' => "",
'suffix' => "",
'width' => "",
'value' => array('y' => "<div id=\"ir-Yes\" class=\"swap\"><span>Yes</span></div>",'n' => "<div class=\"swap\" id=\"ir-No\"><span>No</span></div>"));
$liste["item"][] = array( 'field' => "circle_name",
'datatype' => "VARCHAR",
'formtype' => "TEXT",
'op' => "like",
'prefix' => "%",
'suffix' => "%",
'width' => "",
'value' => "");
$liste["item"][] = array( 'field' => "description",
'datatype' => "VARCHAR",
'formtype' => "TEXT",
'op' => "like",
'prefix' => "%",
'suffix' => "%",
'width' => "",
'value' => "");
?>
\ No newline at end of file
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_client">
<div class="pnl_formsarea">
<fieldset class="inlineLabels"><legend>{tmpl_var name='circle_txt'}</legend>
<div class="ctrlHolder">
<label for="circle_name">{tmpl_var name='circle_name_txt'}*</label>
<input name="circle_name" id="circle_name" value="{tmpl_var name='circle_name'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='client_ids_txt'}</p>
<div class="multiField">
{tmpl_var name='client_ids'}
</div>
</div>
<div class="ctrlHolder">
<label for="description">{tmpl_var name='description_txt'}</label>
<textarea name="description" id="description" rows='10' cols='30'>{tmpl_var name='description'}</textarea>
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='active_txt'}</p>
<div class="multiField">
{tmpl_var name='active'}
</div>
</div>
{tmpl_var name='required_fields_txt'}
</fieldset>
<input type="hidden" name="id" value="{tmpl_var name='id'}">
<div class="buttonHolder buttons">
<button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','client/client_circle_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
<button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('client/client_circle_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
</div>
</div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>