summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Wrobel <wrobel@pardus.de>2010-04-06 10:18:55 (GMT)
committerGunnar Wrobel <wrobel@pardus.de>2010-04-06 10:18:55 (GMT)
commit6d04cf10781bb761d3f19a44847d6128c57abd2d (patch)
treea4f8b599480e68a053db53e06eaf257bd87ac0fe
parent4fa63dcb7d33866f4a26c4d0c30fa3a878b4275c (diff)
downloadkolab-webadmin-6d04cf10781bb761d3f19a44847d6128c57abd2d.tar.gz
The new handler reads the old forward and vacation scripts just fine.
In addition this switches from the patched PEAR-Net_Sieve in kolab-webadmin/php/admin/include/Sieve.php to the standard PEAR-Net_Sieve package. The patched version was imported as is into Kolab CVS. There is no hint if there was anything specific that needed patching or what has actually been patched. The diff to the current PEAR-Net_Sieve also did not indicate anything that looked like it might be specific to the Kolab server. The patched version did however fail to work with the new handler as it was not able to load several sieve scripts in succession (which is necessary to avoid loosing data).
-rw-r--r--www/admin/user/deliver.php.in2
-rw-r--r--www/admin/user/forward.php.in24
-rw-r--r--www/admin/user/vacation.php.in53
3 files changed, 28 insertions, 51 deletions
diff --git a/www/admin/user/deliver.php.in b/www/admin/user/deliver.php.in
index a3f5f1e..d845766 100644
--- a/www/admin/user/deliver.php.in
+++ b/www/admin/user/deliver.php.in
@@ -38,7 +38,7 @@ function undotstuff( $str ) {
}
$errors = array();
-if( (@include_once '@kolab_php_module_prefix@admin/include/Sieve.php' ) === false ) {
+if( (@include_once 'Net/Sieve.php' ) === false ) {
$errors[] = _('Net/Sieve.php is missing. Without that, filter settings are not available');
$errors[] = _("Suggest your system administrator to run \"pear install http://pear.php.net/get/Net_Sieve\" on the server");
}
diff --git a/www/admin/user/forward.php.in b/www/admin/user/forward.php.in
index db83d2f..eb38eb8 100644
--- a/www/admin/user/forward.php.in
+++ b/www/admin/user/forward.php.in
@@ -22,7 +22,12 @@ require_once '@kolab_php_module_prefix@admin/include/mysmarty.php';
require_once '@kolab_php_module_prefix@admin/include/headers.php';
require_once('@kolab_php_module_prefix@admin/include/locale.php');
require_once '@kolab_php_module_prefix@admin/include/authenticate.php';
+require_once 'KolabAdmin/Sieve.php';
require_once 'KolabAdmin/Sieve/Script.php';
+require_once 'KolabAdmin/Sieve/Segment.php';
+require_once 'KolabAdmin/Sieve/Segment/Delivery.php';
+require_once 'KolabAdmin/Sieve/Segment/Forward.php';
+require_once 'KolabAdmin/Sieve/Segment/Vacation.php';
// Funny multiline string escaping in Sieve
function dotstuff( $str ) {
@@ -34,7 +39,7 @@ function undotstuff( $str ) {
}
$errors = array();
-if( (@include_once '@kolab_php_module_prefix@admin/include/Sieve.php' ) === false ) {
+if( (@include_once 'Net/Sieve.php' ) === false ) {
$errors[] = _('Net/Sieve.php is missing. Without that, vacation settings are not available');
$errors[] = _("Suggest your system administrator to run \"pear install http://pear.php.net/get/Net_Sieve\" on the server");
}
@@ -84,16 +89,7 @@ if( !$errors ) {
}
}
- $scripts = $sieve->listScripts();
- if( in_array( $scriptname, $scripts ) ) {
- $script = $sieve->getScript($scriptname);
- $address = KolabAdmin_Sieve_Script::getForwardAddress( $script );
- $keep = KolabAdmin_Sieve_Script::getKeepOnServer( $script );
- } else {
- $address = '';
- $keep = true;
- }
- $active = ( $sieve->getActive() === $scriptname );
+ $handler = new KolabAdmin_Sieve($sieve);
}
/**** Insert into template and output ***/
@@ -107,9 +103,9 @@ $smarty->assign( 'menuitems', $menuitems );
$smarty->assign( 'submenuitems',
array_key_exists('submenu',
$menuitems[$sidx])?$menuitems[$sidx]['submenu']:array() );
-$smarty->assign( 'active', $active );
-$smarty->assign( 'keep', $keep );
-$smarty->assign( 'address', $address );
+$smarty->assign( 'active', $handler->fetchForwardSegment()->isActive() );
+$smarty->assign( 'keep', $handler->fetchForwardSegment()->getKeepOnServer() );
+$smarty->assign( 'address', $handler->fetchForwardSegment()->getForwardAddress() );
$smarty->assign( 'maincontent', 'forward.tpl' );
$smarty->display('page.tpl');
diff --git a/www/admin/user/vacation.php.in b/www/admin/user/vacation.php.in
index cbd47c4..0b0008a 100644
--- a/www/admin/user/vacation.php.in
+++ b/www/admin/user/vacation.php.in
@@ -10,10 +10,15 @@ require_once '@kolab_php_module_prefix@admin/include/mysmarty.php';
require_once '@kolab_php_module_prefix@admin/include/headers.php';
require_once('@kolab_php_module_prefix@admin/include/locale.php');
require_once '@kolab_php_module_prefix@admin/include/authenticate.php';
+require_once 'KolabAdmin/Sieve.php';
require_once 'KolabAdmin/Sieve/Script.php';
+require_once 'KolabAdmin/Sieve/Segment.php';
+require_once 'KolabAdmin/Sieve/Segment/Delivery.php';
+require_once 'KolabAdmin/Sieve/Segment/Forward.php';
+require_once 'KolabAdmin/Sieve/Segment/Vacation.php';
$errors = array();
-if( (@include_once '@kolab_php_module_prefix@admin/include/Sieve.php' ) === false ) {
+if( (@include_once 'Net/Sieve.php' ) === false ) {
$errors[] = _('Net/Sieve.php is missing. Without that, vacation settings are not available');
$errors[] = _("Suggest your system administrator to run \"pear install http://pear.php.net/get/Net_Sieve\" on the server");
}
@@ -70,36 +75,13 @@ if( !$errors ) {
}
}
- $addresses = $days = $text = false;
- $scripts = $sieve->listScripts();
- if( in_array( $scriptname, $scripts ) ) {
- $script = $sieve->getScript($scriptname);
- $maildomain = KolabAdmin_Sieve_Script::getMailDomain( $script );
- $reacttospam = KolabAdmin_Sieve_Script::getReactToSpam( $script );
- debug("reacttospam=".($reacttospam?"true":"false"));
- $addresses = KolabAdmin_Sieve_Script::getVacationAddresses( $script );
- $days = KolabAdmin_Sieve_Script::getVacationDays( $script );
- $text = KolabAdmin_Sieve_Script::getVacationText( $script );
- } else $reacttospam = true;
- if( $addresses === false ) {
- $object = $ldap->read( $auth->dn() );
- $addresses = array_merge( (array)$object['mail'], (array)$object['alias'] );
- }
- if( $days === false || $days < 1 ) $days = 7;
- if( $text === false ) {
- $date = strftime(_('%x'));
- $text = sprintf(
- _("I am out of office until %s.\r\n").
- _("In urgent cases, please contact Mrs. <vacation replacement>\r\n\r\n").
- _("email: <email address of vacation replacement>\r\n").
- _("phone: +49 711 1111 11\r\n").
- _("fax.: +49 711 1111 12\r\n\r\n").
- _("Yours sincerely,\r\n").
- _("-- \r\n").
- _("<enter your name and email address here>"),
- $date);
+ $handler = new KolabAdmin_Sieve($sieve);
+
+ $addresses = $handler->fetchVacationSegment()->getRecipientAddresses();
+ if (empty($addresses)) {
+ $object = $ldap->read($auth->dn());
+ $addresses = array_merge((array) $object['mail'], (array) $object['alias']);
}
- $active = ( $sieve->getActive() === $scriptname );
}
/**** Insert into template and output ***/
@@ -113,13 +95,12 @@ $smarty->assign( 'menuitems', $menuitems );
$smarty->assign( 'submenuitems',
array_key_exists('submenu',
$menuitems[$sidx])?$menuitems[$sidx]['submenu']:array() );
-$smarty->assign( 'active', $active );
-$smarty->assign( 'text', $text );
+$smarty->assign( 'active', $handler->fetchVacationSegment()->isActive() );
+$smarty->assign( 'text', $handler->fetchVacationSegment()->getResponse() );
$smarty->assign( 'addresses', $addresses );
-$smarty->assign( 'maildomain', $maildomain );
-$smarty->assign( 'reacttospam', $reacttospam );
-$smarty->assign( 'days', $days );
-$smarty->assign( 'inbox', $inbox );
+$smarty->assign( 'maildomain', $handler->fetchVacationSegment()->getDomain() );
+$smarty->assign( 'reacttospam', !$handler->fetchVacationSegment()->getReactToSpam() );
+$smarty->assign( 'days', $handler->fetchVacationSegment()->getResendAfter() );
$smarty->assign( 'maincontent', 'vacation.tpl' );
$smarty->display('page.tpl');