summaryrefslogtreecommitdiff
path: root/www/admin
diff options
context:
space:
mode:
authorGunnar Wrobel <wrobel@pardus.de>2010-04-06 17:49:19 (GMT)
committerGunnar Wrobel <wrobel@pardus.de>2010-04-06 17:49:19 (GMT)
commit0b2bffffa2b181f97d17552909916566ec1d8bd1 (patch)
tree7d6b15f75363e601fd8c959e07cd8bc2dd706316 /www/admin
parent27499aef5d45f270207b04175bb6ecbfe359fc8c (diff)
downloadkolab-webadmin-0b2bffffa2b181f97d17552909916566ec1d8bd1.tar.gz
And finally replace the code in the controllers with the new script generator.
Diffstat (limited to 'www/admin')
-rw-r--r--www/admin/user/deliver.php.in37
-rw-r--r--www/admin/user/forward.php.in40
-rw-r--r--www/admin/user/vacation.php.in65
3 files changed, 63 insertions, 79 deletions
diff --git a/www/admin/user/deliver.php.in b/www/admin/user/deliver.php.in
index d845766..9140ac2 100644
--- a/www/admin/user/deliver.php.in
+++ b/www/admin/user/deliver.php.in
@@ -62,29 +62,26 @@ if( !$errors ) {
$errors[] = _('Error while connecting to Sieve service:');
$errors[] = $sieve->getError();
// Update sieve script on server in case we have submit data
- } elseif( $_REQUEST['submit'] ) {
- $inbox = trim($_REQUEST['inbox']);
- $active = isset($_REQUEST['active']);
+ } else {
+ try {
+ $handler = new KolabAdmin_Sieve($sieve);
- $script =
- "require \"fileinto\";\r\nif header :contains [\"X-Kolab-Scheduling-Message\"] [\"FALSE\"] {\r\nfileinto \"INBOX/$inbox\";\r\n}\r\n";
-
- if( PEAR::isError( $res = $sieve->installScript( $scriptname, $script, $active ) ) ) {
- $errors[] = $res->getMessage();
- $errors[] = _('Script was:');
- $errors[] = '<pre>'.MySmarty::htmlentities($script).'</pre>';
- }
- if( !$active && $sieve->getActive() === $scriptname ) {
- $sieve->setActive( '' );
+ if ($_REQUEST['submit']) {
+ $handler->fetchDeliverySegment()->setActive($_REQUEST['active']);
+ $handler->fetchDeliverySegment()->setDeliveryFolder($_REQUEST['inbox']);
+ $handler->store();
+ if ($_REQUEST['active']) {
+ $messages[] = sprintf(_("Delivery to '%s' successfully activated"), $_REQUEST['inbox']);
+ } else {
+ $messages[] = sprintf(_("Delivery to '%s' successfully deactivated"), $_REQUEST['inbox']);
+ }
}
-
- if( !$errors ) {
- if( $active ) $messages[] = sprintf(_("Delivery to '%s' successfully activated"), $inbox);
- else $messages[] = sprintf(_("Delivery to '%s' successfully deactivated"), $inbox);
- }
+ } catch (Exception $e) {
+ $errors[] = $e->getMessage();
+ $errors[] = 'Script was:';
+ $errors[] = '<pre>' . $handler->getScript() . '</pre>';
+ }
}
-
- $handler = new KolabAdmin_Sieve($sieve);
}
/**** Insert into template and output ***/
diff --git a/www/admin/user/forward.php.in b/www/admin/user/forward.php.in
index eb38eb8..6321139 100644
--- a/www/admin/user/forward.php.in
+++ b/www/admin/user/forward.php.in
@@ -63,33 +63,27 @@ if( !$errors ) {
$errors[] = _('Error while connecting to Sieve service:');
$errors[] = $sieve->getError();
// Update sieve script on server in case we have submit data
- } elseif( $_REQUEST['submit'] ) {
- $address = trim($_REQUEST['address']);
- $keep = isset($_REQUEST['keep']);
- $active = isset($_REQUEST['active']);
+ } else {
+ try {
+ $handler = new KolabAdmin_Sieve($sieve);
- if( empty( $address ) ) {
- $errors[] = _('Please enter an email address');
- } else {
- $script =
- "require \"fileinto\";\r\nredirect \"".addslashes($address)."\";".($keep?" keep;":"");
- if( PEAR::isError( $res = $sieve->installScript( $scriptname, $script, $active ) ) ) {
- $errors[] = $res->getMessage();
- $errors[] = _('Script was:');
- $errors[] = '<pre>'.MySmarty::htmlentities($script).'</pre>';
- }
- if( !$active && $sieve->getActive() === $scriptname ) {
- $sieve->setActive( '' );
- }
-
- if( !$errors ) {
- if( $active ) $messages[] = sprintf(_("Forwarding to '%s' successfully activated"), $address);
- else $messages[] = sprintf(_("Forwarding to '%s' successfully deactivated"), $address);
+ if ($_REQUEST['submit']) {
+ $handler->fetchForwardSegment()->setActive($_REQUEST['active']);
+ $handler->fetchForwardSegment()->setForwardAddress($_REQUEST['address']);
+ $handler->fetchForwardSegment()->setKeepOnServer($_REQUEST['keep']);
+ $handler->store();
+ if ($_REQUEST['active']) {
+ $messages[] = sprintf(_("Forwarding to '%s' successfully activated"), $_REQUEST['address']);
+ } else {
+ $messages[] = sprintf(_("Forwarding to '%s' successfully deactivated"), $_REQUEST['address']);
+ }
}
+ } catch (Exception $e) {
+ $errors[] = $e->getMessage();
+ $errors[] = 'Script was:';
+ $errors[] = '<pre>' . $handler->getScript() . '</pre>';
}
}
-
- $handler = new KolabAdmin_Sieve($sieve);
}
/**** Insert into template and output ***/
diff --git a/www/admin/user/vacation.php.in b/www/admin/user/vacation.php.in
index 0b0008a..fe09bbf 100644
--- a/www/admin/user/vacation.php.in
+++ b/www/admin/user/vacation.php.in
@@ -42,45 +42,38 @@ if( !$errors ) {
$errors[] = _('Error while connecting to Sieve service:');
$errors[] = $sieve->getError();
// Update sieve script on server in case we have submit data
- } elseif( $_REQUEST['submit'] ) {
- $addresses = array_unique( array_filter( array_map( 'trim', preg_split( '/\n/', $_REQUEST['addresses'] ) ), 'strlen') );
- $maildomain = trim( $_REQUEST['maildomain'] );
- $reacttospam = isset( $_REQUEST['reacttospam'] );
- $days = $_REQUEST['days'];
- if( $days < 1 ) {
- $errors[] = _('Days must be at least one');
- } else {
- $script =
- "require \"vacation\";\r\n\r\n".
- (!empty($maildomain)?"if not address :domain :contains \"From\" \"".$maildomain."\" { keep; stop; }\r\n":"").
- ($reacttospam?"if header :contains \"X-Spam-Flag\" \"YES\" { keep; stop; }\r\n":"").
- "vacation :addresses [ \"".join('", "', $addresses )."\" ] :days ".
- $_REQUEST['days']." text:\r\n".
- KolabAdmin_Sieve_Script::dotstuff(trim($_REQUEST['text']))."\r\n.\r\n;\r\n\r\n";
- $active = isset($_REQUEST['active']);
-
- if( PEAR::isError( $res = $sieve->installScript( $scriptname, $script, $active ) ) ) {
- $errors[] = $res->getMessage();
- $errors[] = 'Script was:';
- $errors[] = '<pre>'.MySmarty::htmlentities($script).'</pre>';
- }
- if( !$active && $sieve->getActive() === $scriptname ) {
- $sieve->setActive( '' );
- }
- }
+ } else {
+ try {
+ $handler = new KolabAdmin_Sieve($sieve);
- if( !$errors ) {
- if( $active ) $messages[] = _('Vacation message successfully activated');
- else $messages[] = _('Vacation message successfully deactivated');
- }
- }
+ if ($_REQUEST['submit']) {
+ $handler->fetchVacationSegment()->setActive($_REQUEST['active']);
+ $handler->fetchVacationSegment()->setDomain(trim($_REQUEST['maildomain']));
+ $handler->fetchVacationSegment()->setReactToSpam(!isset($_REQUEST['reacttospam']));
+ $handler->fetchVacationSegment()->setResendAfter($_REQUEST['days']);
+ $handler->fetchVacationSegment()->setResponse(trim($_REQUEST['text']));
- $handler = new KolabAdmin_Sieve($sieve);
+ $addresses = array_unique(array_filter(array_map('trim', preg_split('/\n/', $_REQUEST['addresses'])), 'strlen'));
+ $handler->fetchVacationSegment()->setRecipientAddresses($addresses);
- $addresses = $handler->fetchVacationSegment()->getRecipientAddresses();
- if (empty($addresses)) {
- $object = $ldap->read($auth->dn());
- $addresses = array_merge((array) $object['mail'], (array) $object['alias']);
+ $handler->store();
+ if ($_REQUEST['active']) {
+ $messages[] = _('Vacation message successfully activated');
+ } else {
+ $messages[] = _('Vacation message successfully deactivated');
+ }
+ } else {
+ $addresses = $handler->fetchVacationSegment()->getRecipientAddresses();
+ if (empty($addresses)) {
+ $object = $ldap->read($auth->dn());
+ $addresses = array_merge((array) $object['mail'], (array) $object['alias']);
+ }
+ }
+ } catch (Exception $e) {
+ $errors[] = $e->getMessage();
+ $errors[] = 'Script was:';
+ $errors[] = '<pre>' . $handler->getScript() . '</pre>';
+ }
}
}