summaryrefslogtreecommitdiff
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
parent27499aef5d45f270207b04175bb6ecbfe359fc8c (diff)
downloadkolab-webadmin-0b2bffffa2b181f97d17552909916566ec1d8bd1.tar.gz
And finally replace the code in the controllers with the new script generator.
-rw-r--r--php/admin/templates/deliver.tpl4
-rwxr-xr-xphp/admin/templates/forward.tpl4
-rwxr-xr-xphp/admin/templates/vacation.tpl2
-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
6 files changed, 68 insertions, 84 deletions
diff --git a/php/admin/templates/deliver.tpl b/php/admin/templates/deliver.tpl
index d0cb893..bb9155f 100644
--- a/php/admin/templates/deliver.tpl
+++ b/php/admin/templates/deliver.tpl
@@ -7,8 +7,8 @@
<h1>{tr msg="Email Delivery"}</h1>
<div class="contentform">
<form method="POST">
-<input type="checkbox" name="active" value="true" {if $active}checked{/if} /> {tr msg="Activate delivery to folder (only one of vacation, forward and delivery to folder can be active at any time)"}<br />
+<input type="checkbox" name="active" value="true" {if $active}checked{/if} /> {tr msg="Activate delivery to folder"}<br />
{tr msg="Deliver regular mail to folder"} <input type="text" name="inbox" value="{$inbox}" /><br />
<input type="submit" name="submit" value="{tr msg="Update"}"/><br />
</form>
-</div> \ No newline at end of file
+</div>
diff --git a/php/admin/templates/forward.tpl b/php/admin/templates/forward.tpl
index 6ed2eeb..458e093 100755
--- a/php/admin/templates/forward.tpl
+++ b/php/admin/templates/forward.tpl
@@ -7,9 +7,9 @@
<h1>{tr msg="Email Forwarding"}</h1>
<div class="contentform">
<form method="POST">
-<input type="checkbox" name="active" value="true" {if $active}checked{/if} /> {tr msg="Activate email forwarding (only one of vacation, forward and delivery to folder can be active at any time)"}<br />
+<input type="checkbox" name="active" value="true" {if $active}checked{/if} /> {tr msg="Activate email forwarding"}<br />
{tr msg="Forward mail to"} <input type="text" name="address" value="{$address}" /><br />
<input type="checkbox" name="keep" value="true" {if $keep}checked{/if} /> {tr msg="Keep copy on server"}<br />
<input type="submit" name="submit" value="{tr msg="Update"}"/><br />
</form>
-</div> \ No newline at end of file
+</div>
diff --git a/php/admin/templates/vacation.tpl b/php/admin/templates/vacation.tpl
index 47e484b..01fe63c 100755
--- a/php/admin/templates/vacation.tpl
+++ b/php/admin/templates/vacation.tpl
@@ -7,7 +7,7 @@
<h1>{tr msg="Vacation Notification"}</h1>
<div class="contentform">
<form method="post">
-<input type="checkbox" name="active" value="true" {if $active}checked{/if} /> {tr msg="Activate vacation notification (only one of vacation, forward and delivery to folder can be active at any time)"}<br />
+<input type="checkbox" name="active" value="true" {if $active}checked{/if} /> {tr msg="Activate vacation notification"}<br />
<textarea name="text" cols="80" rows="10">{$text|escape}</textarea><br />
{tr msg="Resend notification only after"} <input type="text" size="5" name="days" value="{$days}" /> {tr msg="days"}<br />
{tr msg="Send responses for these addresses:"}<br />
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>';
+ }
}
}