mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 09:05:16 +01:00
handle vacation notice on mail-index page; check and refresh on changeFolder; refresh on editVacation
This commit is contained in:
parent
2cf37face0
commit
a4efec4997
@ -526,6 +526,7 @@ class mail_sieve
|
||||
if ($this->mailbo->icServer->enableSieve)
|
||||
{
|
||||
$vacRules = $this->getVacation($vacation,$msg);
|
||||
//$this->timed_vacation=true;//this could force the timed vacation thingy even if not supported ;-)
|
||||
if ($this->timed_vacation)
|
||||
{
|
||||
include_once(EGW_API_INC.'/class.jscalendar.inc.php');
|
||||
@ -616,9 +617,13 @@ class mail_sieve
|
||||
{
|
||||
$msg .= implode("\n",$this->errorStack);
|
||||
}
|
||||
// refresh vacationNotice on index
|
||||
$response = egw_json_response::get();
|
||||
$response->call('app.mail.mail_callRefreshVacationNotice',$this->mailbo->profileID);
|
||||
egw_framework::refresh_opener($msg, 'mail','edit');
|
||||
if ($button === 'apply') break;
|
||||
}
|
||||
|
||||
case 'cancel':
|
||||
egw_framework::window_close();
|
||||
|
||||
|
@ -413,6 +413,21 @@ class mail_ui
|
||||
$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone";
|
||||
}
|
||||
|
||||
$vacation = $this->gatherVacation();
|
||||
//error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation));
|
||||
if($vacation) {
|
||||
if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date'))
|
||||
{
|
||||
$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/;
|
||||
$content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = lang('Vacation notice is active');
|
||||
$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ($vacation['status']=='by_date'? common::show_date($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.common::show_date($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
|
||||
}
|
||||
}
|
||||
if ($vacation==false)
|
||||
{
|
||||
$content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = '';
|
||||
$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = '';
|
||||
}
|
||||
//$zstarttime = microtime (true);
|
||||
$sel_options[self::$nm_index]['foldertree'] = $this->getFolderTree('initial',null,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
|
||||
//$zendtime = microtime(true) - $zstarttime;
|
||||
@ -2417,9 +2432,40 @@ unset($query['actions']);
|
||||
}
|
||||
|
||||
/**
|
||||
* display image
|
||||
*
|
||||
* gatherVacation
|
||||
*
|
||||
* fetch vacation info from active Server using the oldIMAPObject
|
||||
* @return mixed array/boolean - array with vacation on success; false on failure
|
||||
*/
|
||||
function gatherVacation()
|
||||
{
|
||||
$vacation = $this->mail_bo->icServer->acc_sieve_enabled && $this->mail_bo->icServer->acc_sieve_host;
|
||||
//error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation));
|
||||
if($vacation) {
|
||||
$sieveServerClass = mail_bo::getInstance(false, self::$icServerID, false, $oldIMAPObject=true);
|
||||
$sieveServer = $sieveServerClass->icServer;
|
||||
//error_log(__METHOD__.__LINE__.' Sieve Server:'.self::$icServerID.' InstanceOf:'.array2string(($sieveServer instanceof defaultimap)|| ($sieveServer instanceof emailadmin_oldimap)).':'.array2string($sieveServerClass));
|
||||
if(($sieveServer instanceof defaultimap) || ($sieveServer instanceof emailadmin_oldimap)) {
|
||||
$scriptName = (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['sieveScriptName'])) ? $GLOBALS['egw_info']['user']['preferences']['mail']['sieveScriptName'] : 'felamimail';
|
||||
$sieveServer->getScript($scriptName);
|
||||
$rules = $sieveServer->retrieveRules($sieveServer->scriptName,true);
|
||||
$vacation = $sieveServer->getVacation($sieveServer->scriptName);
|
||||
$isSieveError = egw_cache::getCache(egw_cache::INSTANCE,'email','icServerSIEVE_connectionError'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*15);
|
||||
if ($isSieveError[self::$icServerID])
|
||||
{
|
||||
$vacation = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $vacation;
|
||||
}
|
||||
|
||||
/**
|
||||
* quotaDisplay
|
||||
* gather Info on how to display the quota info
|
||||
* @param $_usage int
|
||||
* @param $_limit int
|
||||
* @return array - info used for quota array(class=>string,text=>string,$percent=>string)
|
||||
*/
|
||||
function quotaDisplay($_usage, $_limit)
|
||||
{
|
||||
@ -3965,6 +4011,38 @@ $this->partID = $partID;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ajax_refreshVacationNotice - its called via json, so the function must start with ajax (or the class-name must contain ajax)
|
||||
* Note: only the activeProfile VacationNotice is refreshed
|
||||
* @param int $icServerId profileId / server ID to work on; may be empty -> then activeProfile is used
|
||||
* if other than active profile; nothing is done!
|
||||
* @return nothing
|
||||
*/
|
||||
function ajax_refreshVacationNotice($icServerId=null)
|
||||
{
|
||||
//error_log(__METHOD__.__LINE__.array2string($icServerId));
|
||||
if (empty($icServerID)) $icServerID = $this->mail_bo->profileID;
|
||||
if ($icServerID != $this->mail_bo->profileID) return;
|
||||
$vacation = $this->gatherVacation();
|
||||
//error_log(__METHOD__.__LINE__.array2string($vacation));
|
||||
if($vacation) {
|
||||
if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date'))
|
||||
{
|
||||
$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/;
|
||||
$refreshData['vacationnotice'] = lang('Vacation notice is active');
|
||||
$refreshData['vacationrange'] = ($vacation['status']=='by_date'? common::show_date($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.common::show_date($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
|
||||
}
|
||||
}
|
||||
if ($vacation==false)
|
||||
{
|
||||
$refreshData['vacationnotice'] = '';
|
||||
$refreshData['vacationrange'] = '';
|
||||
}
|
||||
|
||||
$response = egw_json_response::get();
|
||||
$response->call('app.mail.mail_refreshVacationNotice',$refreshData);
|
||||
}
|
||||
|
||||
/**
|
||||
* ajax_refreshQuotaDisplay - its called via json, so the function must start with ajax (or the class-name must contain ajax)
|
||||
*
|
||||
|
@ -805,6 +805,38 @@ app.classes.mail = AppJS.extend(
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* mail_callRefreshVacationNotice, function to call the serverside function to refresh the vacationnotice for the active server
|
||||
*
|
||||
*/
|
||||
mail_callRefreshVacationNotice: function(_server)
|
||||
{
|
||||
egw.jsonq('mail.mail_ui.ajax_refreshVacationNotice',[_server]);
|
||||
},
|
||||
|
||||
/**
|
||||
* mail_refreshVacationNotice, function to call with appropriate data to refresh the vacationnotice for the active server
|
||||
*
|
||||
*/
|
||||
mail_refreshVacationNotice: function(_data)
|
||||
{
|
||||
//this.et2 should do the same as etemplate2.getByApplication('mail')[0].widgetContainer
|
||||
//var vacationnotice = this.et2.getWidgetById(this.nm_index+'[vacationnotice]');
|
||||
//var vacationrange = this.et2.getWidgetById(this.nm_index+'[vacationrange]');
|
||||
//console.log(_data,vacationnotice,vacationrange);
|
||||
//try to set it via set_value and set label
|
||||
if (_data == null)
|
||||
{
|
||||
this.et2.getWidgetById(this.nm_index+'[vacationnotice]').set_value('');
|
||||
this.et2.getWidgetById(this.nm_index+'[vacationrange]').set_value('');
|
||||
}
|
||||
else
|
||||
{
|
||||
this.et2.getWidgetById(this.nm_index+'[vacationnotice]').set_value(_data.vacationnotice);
|
||||
this.et2.getWidgetById(this.nm_index+'[vacationrange]').set_value(_data.vacationrange);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Queues a refreshFolderList request for 10ms. Actually this will just execute the
|
||||
* code after the calling script has finished.
|
||||
@ -1247,6 +1279,8 @@ app.classes.mail = AppJS.extend(
|
||||
this.mail_refreshQuotaDisplay(server[0]);
|
||||
this.mail_fetchCurrentlyFocussed(null,true);
|
||||
this.mail_preview();
|
||||
if (server[0]!=previousServer[0]) this.mail_callRefreshVacationNotice(server[0]);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -298,6 +298,19 @@ pre {
|
||||
width:200px !important;
|
||||
z-index:99;
|
||||
}
|
||||
.mail-index_vacation {
|
||||
position: absolute;
|
||||
top:3px;
|
||||
right:190px;
|
||||
width:250px !important;
|
||||
z-index:99;
|
||||
}
|
||||
.mail-index_vacation > div {
|
||||
text-align: center;
|
||||
}
|
||||
.mail-index_vacation > div > span {
|
||||
color: red;
|
||||
}
|
||||
.mail_DisplayNone {
|
||||
display: none !important;
|
||||
}
|
||||
|
@ -45,6 +45,10 @@
|
||||
<html id="msg"/>
|
||||
<buttononly id="button[mailcreate]" onclick="app.mail.mail_compose(false);" label="Compose" parent_node="mail-index_buttonmailcreate"/>
|
||||
<hbox class="mail-index_quotabox"><progress id="nm[quotainpercent]" label="@nm[quota]" class="@nm[quotaclass]"/></hbox>
|
||||
<hbox class="mail-index_vacation"><vbox>
|
||||
<description id="nm[vacationnotice]" class="@nm[vacationclass]"/>
|
||||
<description id="nm[vacationrange]" class="@nm[vacationrangeclass]"/></vbox>
|
||||
</hbox>
|
||||
<split dock_side="bottomDock" id="mailSplitter" orientation="h">
|
||||
<nextmatch id="nm" onselect="app.mail.mail_preview" template="mail.index.rows"/>
|
||||
<vbox id="mailPreview" width="100%">
|
||||
|
@ -296,6 +296,19 @@ pre {
|
||||
width: 200px !important;
|
||||
z-index: 99;
|
||||
}
|
||||
.mail-index_vacation {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
right: 190px;
|
||||
width: 250px !important;
|
||||
z-index: 99;
|
||||
}
|
||||
.mail-index_vacation > div {
|
||||
text-align: center;
|
||||
}
|
||||
.mail-index_vacation > div > span {
|
||||
color: red;
|
||||
}
|
||||
.mail_DisplayNone {
|
||||
display: none !important;
|
||||
}
|
||||
@ -2054,6 +2067,19 @@ pre {
|
||||
background-color: red !important;
|
||||
height: 4px !important;
|
||||
}
|
||||
.mail-index_vacation {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
right: 190px;
|
||||
width: 250px !important;
|
||||
z-index: 99;
|
||||
}
|
||||
.mail-index_vacation > div {
|
||||
text-align: center;
|
||||
}
|
||||
.mail-index_vacation > div > span {
|
||||
color: red;
|
||||
}
|
||||
/*
|
||||
influence the tree display and scrolling behavior
|
||||
*/
|
||||
|
@ -1406,6 +1406,19 @@ pre {
|
||||
height:4px !important;
|
||||
}
|
||||
|
||||
.mail-index_vacation {
|
||||
position: absolute;
|
||||
top:3px;
|
||||
right:190px;
|
||||
width:250px !important;
|
||||
z-index:99;
|
||||
}
|
||||
.mail-index_vacation > div {
|
||||
text-align: center;
|
||||
}
|
||||
.mail-index_vacation > div > span {
|
||||
color: red;
|
||||
}
|
||||
|
||||
/*
|
||||
influence the tree display and scrolling behavior
|
||||
|
Loading…
Reference in New Issue
Block a user