mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
be more verbose on errors and return full Sieve script text (for user/password, not for admin connection)
This commit is contained in:
parent
da49ce2924
commit
2022adfbfb
@ -183,7 +183,7 @@ class Script
|
|||||||
$this->pcount = $rule['priority'];
|
$this->pcount = $rule['priority'];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "vacation" :
|
case "vacation" : // #vacation&&1:days&&2:addresses&&3:text&&4:status/start-end&&5:forwards&&6:modus
|
||||||
if (preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)&&(.*)&&(.*)/i",$line,$bits) ||
|
if (preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)&&(.*)&&(.*)/i",$line,$bits) ||
|
||||||
preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)&&(.*)/i",$line,$bits) ||
|
preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)&&(.*)/i",$line,$bits) ||
|
||||||
preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)/i",$line,$bits)) {
|
preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)/i",$line,$bits)) {
|
||||||
@ -671,7 +671,11 @@ class Script
|
|||||||
$connection->installScript($this->name, $newscript, true);
|
$connection->installScript($this->name, $newscript, true);
|
||||||
}
|
}
|
||||||
catch (\Exception $e) {
|
catch (\Exception $e) {
|
||||||
if ($throw_exceptions) throw $e;
|
if ($throw_exceptions)
|
||||||
|
{
|
||||||
|
$e->script = $newscript;
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
$this->errstr = 'updateScript: putscript failed: ' . $e->getMessage().($e->details?': '.$e->details:'');
|
$this->errstr = 'updateScript: putscript failed: ' . $e->getMessage().($e->details?': '.$e->details:'');
|
||||||
if ($regexused && !$this->extensions['regex']) $this->errstr .= " REGEX is not an supported CAPABILITY";
|
if ($regexused && !$this->extensions['regex']) $this->errstr .= " REGEX is not an supported CAPABILITY";
|
||||||
error_log(__METHOD__.__LINE__.' # Error: ->'.$this->errstr);
|
error_log(__METHOD__.__LINE__.' # Error: ->'.$this->errstr);
|
||||||
|
@ -41,6 +41,11 @@ class Sieve extends Horde\ManageSieve
|
|||||||
*/
|
*/
|
||||||
var $scriptName;
|
var $scriptName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string full Sieve script as text
|
||||||
|
*/
|
||||||
|
var $script;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array $rules containing the rules
|
* @var array $rules containing the rules
|
||||||
*/
|
*/
|
||||||
@ -219,6 +224,7 @@ class Sieve extends Horde\ManageSieve
|
|||||||
catch (\Exception $e) {
|
catch (\Exception $e) {
|
||||||
unset($e); // ignore not found script exception
|
unset($e); // ignore not found script exception
|
||||||
}
|
}
|
||||||
|
$this->script =& $script->script;
|
||||||
$this->rules =& $script->rules;
|
$this->rules =& $script->rules;
|
||||||
$this->vacation =& $script->vacation;
|
$this->vacation =& $script->vacation;
|
||||||
$this->emailNotification =& $script->emailNotification; // Added email notifications
|
$this->emailNotification =& $script->emailNotification; // Added email notifications
|
||||||
|
@ -143,6 +143,23 @@ class ApiHandler extends Api\CalDAV\Handler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get vacation array from server
|
||||||
|
*
|
||||||
|
* @param Api\Mail\Imap $imap
|
||||||
|
* @param ?int $user
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected static function getVacation(Api\Mail\Imap $imap, int $user=null)
|
||||||
|
{
|
||||||
|
if ($GLOBALS['egw']->session->token_auth)
|
||||||
|
{
|
||||||
|
return $imap->getVacationUser($user ?: $GLOBALS['egw_info']['user']['account_id']);
|
||||||
|
}
|
||||||
|
$sieve = new Api\Mail\Sieve($imap);
|
||||||
|
return $sieve->getVacation()+['script' => $sieve->script];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update vacation message/handling with JSON data given in $content
|
* Update vacation message/handling with JSON data given in $content
|
||||||
*
|
*
|
||||||
@ -159,7 +176,7 @@ class ApiHandler extends Api\CalDAV\Handler
|
|||||||
$vacation = $account->imapServer()->getVacationUser($user);
|
$vacation = $account->imapServer()->getVacationUser($user);
|
||||||
if (!($update = json_decode($content, true, 3, JSON_THROW_ON_ERROR)))
|
if (!($update = json_decode($content, true, 3, JSON_THROW_ON_ERROR)))
|
||||||
{
|
{
|
||||||
return throw new \Exeception('Invalid request: no content', 400);
|
throw new \Exeception('Invalid request: no content', 400);
|
||||||
}
|
}
|
||||||
// Sieve class stores them as timestamps
|
// Sieve class stores them as timestamps
|
||||||
foreach(['start', 'end'] as $name)
|
foreach(['start', 'end'] as $name)
|
||||||
@ -218,7 +235,7 @@ class ApiHandler extends Api\CalDAV\Handler
|
|||||||
'status' => 200,
|
'status' => 200,
|
||||||
'message' => 'Vacation handling updated',
|
'message' => 'Vacation handling updated',
|
||||||
'vacation_rule' => $vacation_rule,
|
'vacation_rule' => $vacation_rule,
|
||||||
'vacation' => self::returnVacation($account->imapServer()->getVacationUser($user)),
|
'vacation' => self::returnVacation(self::getVacation($account->imapServer(), $user)),
|
||||||
]), self::JSON_RESPONSE_OPTIONS);
|
]), self::JSON_RESPONSE_OPTIONS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -450,7 +467,7 @@ class ApiHandler extends Api\CalDAV\Handler
|
|||||||
|
|
||||||
case preg_match('#^/mail(/(\d+))?/vacation$#', $path, $matches) === 1:
|
case preg_match('#^/mail(/(\d+))?/vacation$#', $path, $matches) === 1:
|
||||||
$account = self::getMailAccount($user, $matches[2] ?? null);
|
$account = self::getMailAccount($user, $matches[2] ?? null);
|
||||||
echo json_encode(self::returnVacation($account->imapServer()->getVacationUser($user)), self::JSON_RESPONSE_OPTIONS);
|
echo json_encode(self::returnVacation(self::getVacation($account->imapServer(), $user)), self::JSON_RESPONSE_OPTIONS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -463,14 +480,15 @@ class ApiHandler extends Api\CalDAV\Handler
|
|||||||
protected static function returnVacation(array $vacation)
|
protected static function returnVacation(array $vacation)
|
||||||
{
|
{
|
||||||
return array_filter([
|
return array_filter([
|
||||||
'status' => $vacation['status'],
|
'status' => $vacation['status'] ?? 'off',
|
||||||
'start' => isset($vacation['start_date']) ? Api\DateTime::to($vacation['start_date'], 'Y-m-d') : null,
|
'start' => isset($vacation['start_date']) ? Api\DateTime::to($vacation['start_date'], 'Y-m-d') : null,
|
||||||
'end' => $vacation['end_date'] ? Api\DateTime::to($vacation['end_date'], 'Y-m-d') : null,
|
'end' => $vacation['end_date'] ? Api\DateTime::to($vacation['end_date'], 'Y-m-d') : null,
|
||||||
'text' => $vacation['text'],
|
'text' => $vacation['text'] ?? null,
|
||||||
'modus' => $vacation['modus'] ?? "notice+store",
|
'modus' => $vacation['modus'] ?? "notice+store",
|
||||||
'days' => (int)($vacation['days'] ?? 0),
|
'days' => (int)($vacation['days'] ?? 0),
|
||||||
'addresses' => $vacation['addresses'] ?? null,
|
'addresses' => $vacation['addresses'] ?? null,
|
||||||
'forwards' => empty($vacation['forwards']) ? [] : preg_split('/, ?/', $vacation['forwards']),
|
'forwards' => empty($vacation['forwards']) ? [] : preg_split('/, ?/', $vacation['forwards']),
|
||||||
|
'script' => $vacation['script'] ?? null,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,6 +523,8 @@ class ApiHandler extends Api\CalDAV\Handler
|
|||||||
echo json_encode([
|
echo json_encode([
|
||||||
'error' => $code = $e->getCode() ?: 500,
|
'error' => $code = $e->getCode() ?: 500,
|
||||||
'message' => $e->getMessage(),
|
'message' => $e->getMessage(),
|
||||||
|
'details' => $e->details ?? null,
|
||||||
|
'script' => $e->script ?? null,
|
||||||
]+(empty($GLOBALS['egw_info']['server']['exception_show_trace']) ? [] : [
|
]+(empty($GLOBALS['egw_info']['server']['exception_show_trace']) ? [] : [
|
||||||
'trace' => array_map(static function($trace)
|
'trace' => array_map(static function($trace)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user