Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Installation/Configuration

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 15th August 2011, 13:06
osterhase osterhase is offline
Member
 
Join Date: Jul 2011
Location: Germany
Posts: 61
Thanks: 6
Thanked 7 Times in 5 Posts
Default Announce update for mailfilters

Hi there!

I'm still struggeling to implement the possibility for my roundcube users to edit their spamfilters via the webinterface using the according roundcube-plugin. My newest plan:

The filterrules are written into a file (roundcube.sieve) - the syntax of this file is fully understood by ispconfig due to the fact that it is a regular sieve syntax.

I managed to convince the roundcube-plugin to insert the content of the file into dbispconfig.mail_user.custom_mailfilter. But obviously it is not respected by the server.sh as an update and so it is not written into file and takes no effect.

Here is my question: How can I convince ispconfig 3.0.3.3 do run an update for mail_filter_edit?

In a bigger frame: Is that generally possible?

I would - as always - appreciate any suggestions.
Reply With Quote
Sponsored Links
  #2  
Old 15th August 2011, 13:11
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,488
Thanks: 813
Thanked 5,259 Times in 4,123 Posts
Default

Quote:
I managed to convince the roundcube-plugin to insert the content of the file into dbispconfig.mail_user.custom_mailfilter. But obviously it is not respected by the server.sh as an update and so it is not written into file and takes no effect.
If you want to update a field in the ispconfig database, use the datalogUpdate function of the ispconfig mysql library or the remoting API. If you do the updates without these functions, then all changes will be ignored.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #3  
Old 15th August 2011, 16:18
osterhase osterhase is offline
Member
 
Join Date: Jul 2011
Location: Germany
Posts: 61
Thanks: 6
Thanked 7 Times in 5 Posts
Default

Thanks for your fast reply. Just to unterstand the concept:

API: Is basically meant to create an interface between (in this case) roundcube and ISPConfig. A php-script is wirtten that logs into ISPConfig as a remote-user which is equipped with certain rights (f.e. mail-user-edit) and makes certain changes defined in the scirpt.

...so I think I'll try to go with the API-solution.

I had a look at the examples and I think that the soap-mail-user-update.php file is my one. Due to the fact, that I only want to update one field in the db-table I wanted to ask if this is possible via API.

Currently all fields in the array inserted:

Code:
$params = array(	'server_id' => 1,
				'email' => 'test23@domain.ltd',
				'password' => 'testen',
				'quota' => '10',
				'maildir' => '/var/vmail/domain.ltd/test23',
				'homedir' => '/var/vmail',
				'uid' => '5000',
				'gid' => '5000',
				'postfix' => 'y',
				'disableimap' => 'n',
				'disablepop3' => 'n');
If this is not possible and the entire record is written completly new using the mail_user_update function it would be the best way to query the current entries from the db, save them as variables and then send them back to the params array, like:

Code:
$params = array(	'server_id' => 1,
				'email' => $email,
				'password' => $pass,
(...)
Am I correct here or completly of the track?

References:
http://www.howtoforge.com/how-to-cre...or-ispconfig-3

And: /tmp/ispconfig3_install/remoting_client/examples/soap-mailuser-update.php

A punch into any direction is appreciated (whereas "give up" does not count).
Reply With Quote
  #4  
Old 15th August 2011, 16:56
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,488
Thanks: 813
Thanked 5,259 Times in 4,123 Posts
Default

You can not update a single field. A update call has to contain all fields. So the easiest way is to use the mail user get function to retrive the current mailuser, the function returns an array of all fields of that mailuser, then change the value that you intended to cahnge and pass the whole array back as $params to the mail user update function.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #5  
Old 15th August 2011, 18:57
osterhase osterhase is offline
Member
 
Join Date: Jul 2011
Location: Germany
Posts: 61
Thanks: 6
Thanked 7 Times in 5 Posts
Default

Sorry to bother again... do you mean the function that is defined in remoting.inc.php? I got up that bit of the code that calls the function but don't know how to get the array returned or printed. I would appreciate your help.

Ah - by the way - am I right that the primary_id is the mail_user_id? (or how is the mailuser defined?)

Code:
<?php

$username = 'xxx';
$password = 'xxx';

$soap_location = 'http://localhost:8005/remote/index.php';
$soap_uri = 'http://localhost:8005/remote/';


$client = new SoapClient(null, array('location' => $soap_location,
                                     'uri'      => $soap_uri));

try {
	if($session_id = $client->login($username,$password)) {
		echo 'Login sucessful. Session-ID:'.$session_id.'<br />';
	}

	$primary_id = 108;
	$domain__id = $client->mail_user_get($session_id, $primary_id);

		if($client->logout($session_id)) {
		echo 'Logout succesful.<br />';
	}

	
} catch (SoapFault $e) {
	die('SOAP Blad: '.$e->getMessage());
}

?>
Reply With Quote
  #6  
Old 15th August 2011, 19:52
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,488
Thanks: 813
Thanked 5,259 Times in 4,123 Posts
Default

Yes, thats the function. You just have to pass the mailuser_id to the function and it will return the mailuser record-
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #7  
Old 16th August 2011, 11:09
osterhase osterhase is offline
Member
 
Join Date: Jul 2011
Location: Germany
Posts: 61
Thanks: 6
Thanked 7 Times in 5 Posts
Default

Allright it was a little fight, but I figured it out:

Code:
<?php

$username = 'xxx';
$password = 'xxx';

$soap_location = 'http://localhost:8005/remote/index.php';
$soap_uri = 'http://localhost:8005/remote/';


$client = new SoapClient(null, array('location' => $soap_location,
                                     'uri'      => $soap_uri));

try {
	if($session_id = $client->login($username,$password)) {
		echo 'Login sucessful. Session-ID:'.$session_id.'<br />';
	}

// START read out old paramter and hand back $params_old
	$primary_id = 113; // aka mailuser_id
	$domain__id = $client->mail_user_get($session_id, $primary_id);

	$params_old = $domain__id; 
// END read out old parameters


// New entries
	$params = $params_old;
	$params['custom_mailfilter'] = 'test24';
	$client_id = 7; // the ID of the customer who is owning the mail-account
	$mailuser_id = 113; // mailuser_id
	$domain__id = $client->mail_user_update($session_id, $client_id, $mailuser_id , $params);
//	echo $params['custom_mailfilter']; - testing purposes
// ENDE new entries

		if($client->logout($session_id)) {
		echo 'Logout succesful.<br />';
	}

	
} catch (SoapFault $e) {
	die('SOAP Blad: '.$e->getMessage());
}	

?>
But I have two remaining questions:

1. Is the variable "domain_id" changeable or is it in any way dangerous use it twice in the same script? (btw in the example files it is domain__id - is this correct or should domain_id be used?)

2. What's the thing with the client_id? The point being is that I only have the login-name (e-mailadress) of the user which is defined dynamically in the roundcube-sieve-plugin to gather the other informations needed (f.e. the mailuser_id). I'm not shure how to determine the client_id via a mysql-command. Therefore: Is the client_id necessary for the function because it does not seem to apear anywhere except in the client table?

I'm thankful for any suggestions and hints.

Best regards
Reply With Quote
  #8  
Old 16th August 2011, 11:29
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,488
Thanks: 813
Thanked 5,259 Times in 4,123 Posts
Default

Quote:
1. Is the variable "domain_id" changeable or is it in any way dangerous use it twice in the same script? (btw in the example files it is domain__id - is this correct or should domain_id be used?)
The variable should be different, so domain__id with two __ is correct. But you can give the variable a different name like $mailuser_record or similar as well.

Quote:
2. What's the thing with the client_id? The point being is that I only have the login-name (e-mailadress) of the user which is defined dynamically in the roundcube-sieve-plugin to gather the other informations needed (f.e. the mailuser_id). I'm not shure how to determine the client_id via a mysql-command. Therefore: Is the client_id necessary for the function because it does not seem to apear anywhere except in the client table?
Yes, the function is required. If you set a different client-id or no client_id, the mailuser will be moved to a new account.

you can get the client_id with the function client_get_id($session_id, $sys_userid) and the sys_userid is in your $params_old record.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #9  
Old 17th August 2011, 13:54
osterhase osterhase is offline
Member
 
Join Date: Jul 2011
Location: Germany
Posts: 61
Thanks: 6
Thanked 7 Times in 5 Posts
Default

Thanks for your advises - I have implemented the function client_get_id to determine the correct client_id.

But now I've figured a new problem:
When passing the array $params_old to the mailuser_update function the md5 encoded password is encyrpted again. So the md5-encrypted Password is again md5 encrypted and obviously the entered user-password does not match the stored password in the database.

Any suggestions on that?
Reply With Quote
  #10  
Old 17th August 2011, 14:23
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,488
Thanks: 813
Thanked 5,259 Times in 4,123 Posts
 
Default

Set the password column to to a empty string in the $params array.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
Reply

Bookmarks

Tags
roundcube

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
My Centos is terribly slow Galled Server Operation 9 7th December 2010 15:31
Vhosts...conf not synced to changes crypted General 50 24th April 2010 00:54
The system is currently updating the configuration files. warlock General 8 21st February 2009 18:15
High Availability Samba cluster - DRBD + Heartbeat djalex Server Operation 58 25th May 2007 19:38
HotSaNIC domino Tips/Tricks/Mods 23 6th November 2006 05:19


All times are GMT +2. The time now is 19:18.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.