Commit fe670c66 authored by tbrehm's avatar tbrehm

Added SOAP support for mail module. Many thanks to Arkadiusz Roch & Artur...

Added SOAP support for mail module. Many thanks to Arkadiusz Roch & Artur Edelman from Tri-Plex technology
parent 98a9088f
This diff is collapsed.
......@@ -26,6 +26,12 @@ 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.
--UPDATED 08.2009--
Full SOAP support for ISPConfig 3.1.4 b
Updated by Arkadiusz Roch & Artur Edelman
Copyright (c) Tri-Plex technology
*/
/**
......@@ -61,7 +67,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
class remoting_lib {
/**
* Definition of the database atble (array)
* @var tableDef
......@@ -600,7 +606,23 @@ class remoting_lib {
$sql = "SELECT * FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$this->formDef['db_table_idx']." = ".$primary_id;
return $app->db->queryOneRecord($sql);
}
function dodaj_usera($params,$insert_id){
global $app,$sql1;
$username = $params["username"];
$password = $params["password"];
$modules = 'mail,sites,dns,tools';
$startmodule = 'mail';
$usertheme = $params["usertheme"];
$type = 'user';
$active = 1;
$language = $params["language"];
$groupid = $app->db->datalogInsert('sys_group', "(name,description,client_id) VALUES ('$username','','$insert_id')", 'groupid');
$groups = $groupid;
$sql1 = "INSERT INTO sys_user (username,passwort,modules,startmodule,app_theme,typ,active,language,groups,default_group,client_id)
VALUES ('$username',md5('$password'),'$modules','$startmodule','$usertheme','$type','$active','$language',$groups,$groupid,$insert_id)";
$app->db->query($sql1);
}
function datalogSave($action,$primary_id, $record_old, $record_new) {
global $app,$conf;
......@@ -689,4 +711,4 @@ class remoting_lib {
}
?>
\ No newline at end of file
?>
<?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).
*/
$lista_funkcji = array();
$lista_funkcji['mail_domain_get,mail_domain_add,mail_domain_update,mail_domain_delete'] = 'Mail domain functions<br>';
$lista_funkcji['mail_user_add,mail_user_update,mail_user_delete'] = 'Mail user functions<br>';
$lista_funkcji['mail_alias_add,mail_alias_update,mail_alias_delete'] = 'Mail alias functions<br>';
$lista_funkcji['mail_forward_add,mail_forward_update,mail_forward_delete'] = 'Mail forward functions<br>';
$lista_funkcji['mail_catchall_add,mail_catchall_update,mail_catchall_delete'] = 'Mail catchall functions<br>';
$lista_funkcji['mail_transport_add,mail_transport_update,mail_transport_delete'] = 'Mail transport functions<br>';
$lista_funkcji['mail_whitelist_add,mail_whitelist_update,mail_whitelist_delete'] = 'Mail whitelist functions<br>';
$lista_funkcji['mail_blacklist_add,mail_blacklist_update,mail_blacklist_delete'] = 'Mail blacklist functions<br>';
$lista_funkcji['mail_spamfilter_user_add,mail_spamfilter_user_update,mail_spamfilter_user_delete'] = 'Mail spamfilter user functions<br>';
$lista_funkcji['mail_policy_add,mail_policy_update,mail_policy_delete'] = 'Mail spamfilter policy functions<br>';
$lista_funkcji['mail_fetchmail_add,mail_fetchmail_update,mail_fetchmail_delete'] = 'Mail fetchmail functions<br>';
$lista_funkcji['mail_whitelist_add,mail_whitelist_update,mail_whitelist_delete'] = 'Mail whitelist functions<br>';
$lista_funkcji['mail_blacklist_add,mail_blacklist_update,mail_blacklist_delete'] = 'Mail blacklist functions<br>';
$lista_funkcji['mail_filter_add,mail_filter_update,mail_filter_delete'] = 'Mail filter functions<br>';
$form["title"] = "Remote user";
$form["description"] = "";
$form["name"] = "remote_user";
$form["action"] = "remote_user_edit.php";
$form["db_table"] = "remote_user";
$form["db_table_idx"] = "remote_userid";
$form["db_history"] = "yes";
$form["tab_default"] = "remote_user";
$form["list_default"] = "remote_user_list.php";
$form["auth"] = 'yes'; // yes / no
$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
$form["tabs"]['remote_user'] = array (
'title' => "Remote User",
'width' => 100,
'template' => "templates/remote_user_edit.htm",
'fields' => array (
##################################
# Begin Datatable fields
##################################
'remote_userid' => array (
'datatype' => 'INTEGER',
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT remote_userid,remote_username FROM remote_user WHERE {AUTHSQL} ORDER BY remote_username',
'keyfield'=> 'remote_userid',
'valuefield'=> 'remote_username'
),
'value' => ''
),
'remote_username' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'UNIQUE',
'errmsg'=> 'username_error_unique'),
1 => array ( 'type' => 'REGEX',
'regex' => '/^[\w\.\-]{0,64}$/',
'errmsg'=> 'username_error_regex'),
2 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'username_error_empty'),
),
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'remote_password' => array (
'datatype' => 'VARCHAR',
'formtype' => 'PASSWORD',
'encryption' => 'MD5',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'password_error_empty'),
),
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'remote_functions' => array (
'datatype' => 'TEXT',
'formtype' => 'CHECKBOXARRAY',
'regex' => '',
'errmsg' => '',
'default' => '',
'value' => $lista_funkcji,
'separator' => ';',
'width' => '',
'maxlength' => '',
'rows' => '5',
'cols' => '30'
)
##################################
# ENDE Datatable fields
##################################
)
);
?>
<?php
$wb['username_txt'] = 'Username:';
$wb['password_txt'] = 'Password:';
$wb['function_txt'] = 'Functions:';
$wb['username_error_unique'] = 'Username must be unique';
$wb['username_error_empty'] = 'Username cannot be empty';
$wb['password_error_empty'] = 'Password cannot be empty';
$wb['password_strength_txt'] = 'Password Strength:';
?>
<?php
$wb['list_head_txt'] = "Remote Users";
$wb['list_desc_txt'] = "";
$wb['add_new_record_txt'] = "Add new user";
$wb['parent_remote_userid_txt'] = 'ID';
$wb['username_txt'] = "Username";
?>
......@@ -138,6 +138,22 @@ $module['nav'][] = array( 'title' => 'Language Editor',
// cleanup
unset($items);
$items[] = array( 'title' => 'Add user',
'target' => 'content',
'link' => 'admin/remote_user_edit.php');
$items[] = array( 'title' => 'Edit user',
'target' => 'content',
'link' => 'admin/remote_user_list.php');
$module['nav'][] = array( 'title' => 'Remote Users',
'open' => 1,
'items' => $items);
// cleanup
unset($items);
// Getting the admin options from other modules
$modules = explode(',', $_SESSION['s']['user']['modules']);
if(is_array($modules)) {
......
<?php
// Name of the list
$liste['name'] = 'remote_user';
// Database table
$liste['table'] = 'remote_user';
// Index index field of the database table
$liste['table_idx'] = 'userid';
// Search Field Prefix
$liste['search_prefix'] = 'search_';
// Records per page
$liste['records_per_page']= 15;
// Script File of the list
$liste['file'] = 'remote_user_list.php';
// Script file of the edit form
$liste['edit_file'] = 'remote_user_edit.php';
// Script File of the delete script
$liste['delete_file'] = 'remote_user_del.php';
// Paging Template
$liste['paging_tpl'] = 'templates/paging.tpl.htm';
// Enable auth
$liste['auth'] = 'yes';
//****** Search fields
$liste['item'][] = array(
'field' => 'remote_userid',
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'op' => '=',
'prefix' => '',
'suffix' => '',
'width' => '',
'datasource' => array(
'type' => 'SQL',
'querystring' => 'SELECT remote_userid,remote_username FROM remote_user WHERE {AUTHSQL} ORDER BY remote_username',
'keyfield' => 'remote_userid',
'valuefield' => 'remote_userid'
),
'value' => ''
);
$liste['item'][] = array(
'field' => 'remote_username',
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'op' => 'like',
'prefix' => '%',
'suffix' => '%',
'width' => '',
'value' => ''
);
?>
<?php
/*
Copyright (c) 2007, 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/remote_user.list.php";
$tform_def_file = "form/remote_user.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('admin');
$app->uses('tpl,tform');
$app->load('tform_actions');
// Create a class page_action that extends the tform_actions base class
class page_action extends tform_actions {
// Customisations for the page actions will be defined here
}
$page = new page_action;
$page->onDelete();
?>
<?php
// Set the path to the form definition file.
$tform_def_file = 'form/remote_user.tform.php';
// include the core configuration and application classes
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
// Check the module permissions and redirect if not allowed.
if(!stristr($_SESSION['s']['user']['modules'],'admin')) {
header('Location: ../index.php');
die;
}
// Load the templating and form classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
// Create a class page_action that extends the tform_actions base class
class page_action extends tform_actions {
//* Customisations for the page actions will be defined here
}
// Create the new page object
$page = new page_action();
// Start the page rendering and action handling
$page->onLoad();
?>
<?php
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
// Path to the list definition file
$list_def_file = 'list/remote_user.list.php';
// Check the module permissions
if(!stristr($_SESSION['s']['user']['modules'],'admin')) {
header('Location: ../index.php');
die();
}
// Loading the class
$app->uses('listform_actions');
// Optional limit
// $app->listform_actions->SQLExtWhere = 'type = 'alias'';
// Start the form rendering and action ahndling
$app->listform_actions->onLoad();
?>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_ftp_user">
<div class="pnl_formsarea">
<fieldset class="inlineLabels">
<div class="ctrlHolder">
<label for="remote_username">{tmpl_var name='username_txt'}</label>
<div style="float: left;">{tmpl_var name='username_prefix'} </div>
<input name="remote_username" id="username" value="{tmpl_var name='remote_username'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
<div class="ctrlHolder">
<label for="remote_password">{tmpl_var name='password_txt'}</label>
<input name="remote_password" id="password" value="{tmpl_var name='remote_password'}" size="30" maxlength="255" type="password" class="textInput" onkeyup="pass_check(this.value)" />
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='password_strength_txt'}</p>
<div id="passBar"></div>
<p class="formHint"><span id="passText">&nbsp;</span></p>
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='function_txt'}</p>
<div class="multiField">
&nbsp; {tmpl_var name='remote_functions'}
</div>
</div>
</fieldset>
<input type="hidden" name="remote_userid" value="{tmpl_var name='id'}">
<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','admin/remote_user_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('admin/remote_user_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>
<br>
<div class="panel panel_list_ftp_user">
<div class="pnl_toolsarea">
<div class="buttons">
<button class="iconstxt icoAdd" type="button" onClick="loadContent('admin/remote_user_edit.php');">
<span>{tmpl_var name="add_new_record_txt"}</span>
</button>
</div>
</div>
<br>
<div class="pnl_listarea">
<fieldset><legend><tmpl_var name="list_head_txt"></legend>
<table class="list">
<thead>
<tr>
<th class="tbl_col_remote_userid" scope="col"><tmpl_var name="parent_remote_userid_txt"></th>
<th class="tbl_col_username" scope="col"><tmpl_var name="username_txt"></th>
<th class="tbl_col_buttons" scope="col">&nbsp;</th>
</tr>
<tr>
<td class="tbl_col_remote_userid"></td>
<td class="tbl_col_username"><input type="text" name="search_username" value="{tmpl_var name='search_username'}" /></td>
<td class="tbl_col_buttons"><div class="buttons"><button type="button" class="icons16 icoFilter" name="Filter" id="Filter" value="{tmpl_var name="filter_txt"}" onClick="submitForm('pageForm','admin/remote_user_list.php');"><span>{tmpl_var name="filter_txt"}</span></button></div></td>
</tr>
</thead>
<tbody>
<tmpl_loop name="records">
<tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
<td class="tbl_col_remote_userid"><a href="#" onClick="loadContent('admin/remote_user_edit.php?id={tmpl_var name='remote_userid'}');">{tmpl_var name="remote_userid"}</a></td>
<td class="tbl_col_username"><a href="#" onClick="loadContent('admin/remote_user_edit.php?id={tmpl_var name='remote_userid'}');">{tmpl_var name="remote_username"}</a></td>
<td class="tbl_col_buttons">
<div class="buttons icons16">
<a class="icons16 icoDelete" href="javascript: del_record('admin/remote_user_del.php?id={tmpl_var name='remote_userid'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');"><span>{tmpl_var name='delete_txt'}</span></a>
</div>
</td>
</tr>
</tmpl_loop>
</tbody>
<tfoot>
<tr>
<td class="tbl_footer tbl_paging" colspan="5"><tmpl_var name="paging"></td>
</tr>
</tfoot>
</table>
</fieldset>
</div>
</div>
<?php
$username = 'admin';
$password = 'admin';
$soap_location = 'http://localhost:8080/remote/index.php';
$soap_uri = 'http://localhost:8080/remote/';
$client = new SoapClient(null, array('location' => $soap_location,
'uri' => $soap_uri));
try {
if($session_id = $client->login($username,$password)) {
echo 'Zalogowany. Sesja:'.$session_id.'<br />';
}
$params = array( 'server_id' => 1,
'source' => 'stachu@replikant.eu',
'destination' => 'arian@replikant.eu',
'type' => 'alias',
'active' => 'y');
$client_id = 0;
$domain_id = $client->mail_alias_add($session_id,$client_id,$params,$domain_id);
if($client->logout($session_id)) {
echo 'Wylogowany.<br />';
}
} catch (SoapFault $e) {
die('SOAP Blad: '.$e->getMessage());
}
?>
<?php
$username = 'admin';
$password = 'admin';
$soap_location = 'http://localhost:8080/remote/index.php';
$soap_uri = 'http://localhost:8080/remote/';
$client = new SoapClient(null, array('location' => $soap_location,
'uri' => $soap_uri));
try {
if($session_id = $client->login($username,$password)) {
echo 'Zalogowany. Sesja:'.$session_id.'<br />';
}
$client_id = 0;
$mailuser_id = 31;
$domain__id = $client->mail_alias_delete($session_id, $mailuser_id);
if($client->logout($session_id)) {
echo 'Wylogowany.<br />';
}
} catch (SoapFault $e) {
die('SOAP Blad: '.$e->getMessage());
}
?>
<?php
$username = 'admin';
$password = 'admin';
$soap_location = 'http://localhost:8080/remote/index.php';
$soap_uri = 'http://localhost:8080/remote/';
$client = new SoapClient(null, array('location' => $soap_location,
'uri' => $soap_uri));
try {
if($session_id = $client->login($username,$password)) {
echo 'Zalogowany. Sesja:'.$session_id.'<br />';
}
$params = array( 'server_id' => 1,
'source' => 'stachu1234@replikant.eu',
'destination' => 'arian@replikant.eu',
'type' => 'alias',
'active' => 'y');
$client_id = 0;
$mailuser_id = 31;
$domain_id = $client->mail_alias_update($session_id, $mailuser_id, $client_id, $params);
if($client->logout($session_id)) {
echo 'Wylogowany.<br />';
}
} catch (SoapFault $e) {
die('SOAP Blad: '.$e->getMessage());
}
?>
<?php
$username = 'admin';
$password = 'admin';
$soap_location = 'http://localhost:8080/remote/index.php';
$soap_uri = 'http://localhost:8080/remote/';
$client = new SoapClient(null, array('location' => $soap_location,
'uri' => $soap_uri));
try {
if($session_id = $client->login($username,$password)) {
echo 'Zalogowany. Sesja:'.$session_id.'<br />';
}
$params = array( 'server_id' => 1,
'wb' => 'b',
'rid' => '',
'email' => 'ktos@replikant.eu',
'priority' => '4',
'active' => 'y');
$client_id = 0;
$domain_id = $client->mail_blacklist_add($session_id,$client_id,$params,$domain_id);
if($client->logout($session_id)) {
echo 'Wylogowany.<br />';
}
} catch (SoapFault $e) {
die('SOAP Blad: '.$e->getMessage());
}
?>