[prev in list] [next in list] [prev in thread] [next in thread]
List: horde-dev
Subject: [dev] ingo vacation api
From: Duck <duck () obala ! net>
Date: 2007-12-31 15:30:54
Message-ID: 200712311630.54209.duck () obala ! net
[Download RAW message or body]
I am writing an user profile application. Users will be able to set their
vacation message to be show in their public profile page. I will like that
the vacation is set event in their mail boxes if the user has our mail
account. So I patch ingo api to allow set/disable the vacation filter. I
don't now ingo so much, but looking at the code it should be done right.
Duck
["api.diff" (text/x-diff)]
--- api.php 2007-04-23 23:18:42.000000000 +0200
+++ /var/www/localhost/htdocs/horde/ingo/lib/api.php 2007-12-31 16:25:51.000000000 +0100
@@ -47,6 +47,15 @@
'link' => '%application%/filters.php'
);
+$_services['showVacation'] = array(
+ 'link' => '%application%/vacation.php'
+);
+
+$_services['vacation'] = array(
+ 'args' => array('info' => '{urn:horde}stringArray'),
+ 'type' => 'boolean'
+);
+
function _ingo_perms()
{
$perms = array();
@@ -138,3 +147,85 @@
return $ingo_script->perform($params);
}
}
+
+function _ingo_vacation($info)
+{
+ require_once dirname(__FILE__) . '/../lib/base.php';
+ if (!empty($GLOBALS['ingo_shares'])) {
+ $_SESSION['ingo']['current_share'] = $signature;
+ }
+
+ global $ingo_storage;
+
+ /* Get vacation filter. */
+ $filters = &$ingo_storage->retrieve(INGO_STORAGE_ACTION_FILTERS);
+ $vac_id = $filters->findRuleId(INGO_STORAGE_ACTION_VACATION);
+
+ if (empty($info)) {
+ $filters->ruleDisable($vac_id);
+ if (is_a($result = $ingo_storage->store($filters), 'PEAR_Error')) {
+ $GLOBALS['notification']->push($ret, $ret->getCode());
+ $success = false;
+ } else {
+ $success = true;
+ }
+ } else {
+
+ /* Set vacation object and rules. */
+ $vacation = &$ingo_storage->retrieve(INGO_STORAGE_ACTION_VACATION);
+
+ /* Make sure we have at least one address. */
+ if (empty($info['addresses'])) {
+ require_once 'Horde/Identity.php';
+ $identity = &Identity::singleton('none');
+ $info['addresses'] = implode("\n", $identity->getAll('from_addr'));
+ /* Remove empty lines. */
+ $info['addresses'] = preg_replace('/\n+/', "\n", $info['addresses']);
+ if (empty($addresses)) {
+ $info['addresses'] = Auth::getAuth();
+ }
+ }
+
+ $vacation->setVacationAddresses($addresses);
+
+ if (isset($info['days'])) {
+ $vacation->setVacationDays($info['days']);
+ }
+ if (isset($info['excludes'])) {
+ $vacation->setVacationExcludes($info['excludes']);
+ }
+ if (isset($info['ignorelist'])) {
+ $vacation->setVacationIgnorelist(($info['ignorelist'] == 'on'));
+ }
+ if (isset($info['reason'])) {
+ $vacation->setVacationReason($info['reason']);
+ }
+ if (isset($info['subject'])) {
+ $vacation->setVacationSubject($info['subject']);
+ }
+ if (isset($info['start'])) {
+ $vacation->setVacationStart($info['start']);
+ }
+ if (isset($info['end'])) {
+ $vacation->setVacationEnd($info['end']);
+ }
+
+ $filters->ruleEnable($vac_id);
+ if (is_a($result = $ingo_storage->store($filters), 'PEAR_Error')) {
+ $notification->push($result, 'horde.error');
+ $success = false;
+ } else {
+ $notification->push(_("Rule Enabled"), 'horde.success');
+ $vac_rule['disable'] = false;
+ }
+ }
+
+ if ($success && $GLOBALS['prefs']->getValue('auto_update')) {
+ Ingo::updateScript();
+ }
+
+ /* Update the timestamp for the rules. */
+ $_SESSION['ingo']['change'] = time();
+
+ return $success;
+}
\ No newline at end of file
--
Horde developers mailing list - Join the hunt: http://horde.org/bounties/
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: dev-unsubscribe@lists.horde.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic