changeFolder stuff, triggered by javascript directly

This commit is contained in:
Klaus Leithoff 2013-02-12 17:48:04 +00:00
parent 87373194f0
commit bd52ed3756
5 changed files with 103 additions and 8 deletions

View File

@ -2304,6 +2304,29 @@ class mail_bo
return (!empty($folderInfo) && isset($folderInfo[$this->profileID][$_folder]) ? $folderInfo[$this->profileID][$_folder] : false);
}
/**
* remove any messages which are marked as deleted or
* remove any messages from the trashfolder
*
* @param string _folderName the foldername
* @return nothing
*/
function compressFolder($_folderName = false)
{
$folderName = ($_folderName ? $_folderName : $this->sessionData['mailbox']);
$deleteOptions = $GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions'];
$trashFolder = $this->getTrashFolder();
$this->icServer->selectMailbox($folderName);
if($folderName == $trashFolder && $deleteOptions == "move_to_trash") {
$this->icServer->deleteMessages('1:*');
$this->icServer->expunge();
} else {
$this->icServer->expunge();
}
}
/**
* Helper function to handle wrong or unrecognized timezones
* returns the date as it is parseable by strtotime, or current timestamp if everything failes

View File

@ -97,6 +97,17 @@ class mail_ui
//$content['nm']['path'] = self::get_home_dir();
}
}
if ($msg)
{
$content['msg'] = $msg;
}
else
{
unset($msg);
unset($content['msg']);
}
$this->mail_bo->restoreSessionData();
// filter is used to choose the mailbox
//if (!isset($content['nm']['foldertree'])) // maybe we fetch the folder here
/*
@ -112,11 +123,18 @@ class mail_ui
$content['nm']['foldertree'] = '/INBOX/sub';
*/
if ($this->mail_bo->folderExists($this->mail_bo->sessionData['maibox']))
{
$content['nm']['selectedFolder'] = $this->mail_bo->sessionData['maibox'];
}
$sel_options['nm']['foldertree'] = $this->getFolderTree();
$content['nm']['foldertree'] = '/INBOX';
if (!isset($content['nm']['foldertree'])) $content['nm']['foldertree'] = 'INBOX';
if (!isset($content['nm']['selectedFolder'])) $content['nm']['selectedFolder'] = 'INBOX';
$content['nm']['foldertree'] = $content['nm']['selectedFolder'];
$sel_options['cat_id'] = array(1=>'none');
if (!isset($content['nm']['filter'])) $content['nm']['filter'] = 'INBOX';
if (!isset($content['nm']['cat_id'])) $content['nm']['cat_id'] = 'All';
$etpl = new etemplate('mail.index');
return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv);
}
@ -743,15 +761,23 @@ class mail_ui
function get_rows($query,&$rows,&$readonlys)
{
unset($query['actions']);
error_log(__METHOD__.__LINE__.array2string($query));
//error_log(__METHOD__.__LINE__.array2string($query));
error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Start:'.$query['start'].' NumRows:'.$query['num_rows']);
$starttime = microtime(true);
//error_log(__METHOD__.__LINE__.array2string($query['search']));
//$query['search'] is the phrase in the searchbox
//error_log(__METHOD__.__LINE__.' Folder:'.array2string($_folderName).' FolderType:'.$folderType.' RowsFetched:'.array2string($rowsFetched)." these Uids:".array2string($uidOnly).' Headers passed:'.array2string($headers));
$this->mail_bo->restoreSessionData();
$maxMessages = 50; // match the hardcoded setting for data retrieval as inital value
if (isset($this->mail_bo->mailPreferences->preferences['prefMailGridBehavior']) && (int)$this->mail_bo->mailPreferences->preferences['prefMailGridBehavior'] <> 0)
$maxMessages = (int)$this->mail_bo->mailPreferences->preferences['prefMailGridBehavior'];
$previewMessage = $this->sessionData['previewMessage'];
$previewMessage = $this->mail_bo->sessionData['previewMessage'];
if (isset($query['selectedFolder'])) $this->mail_bo->sessionData['maibox']=$query['selectedFolder'];
$this->mail_bo->saveSessionData();
$sRToFetch = null;
$_folderName=$query['filter'];
$_folderName=$query['selectedFolder'];
$rowsFetched['messages'] = null;
$offset = $query['start']+1; // we always start with 1
$maxMessages = $query['num_rows'];
@ -832,6 +858,9 @@ error_log(__METHOD__.__LINE__.array2string($query));
if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]);
$rows = $this->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType,$previewMessage);
//error_log(__METHOD__.__LINE__.array2string($rows));
$endtime = microtime(true) - $starttime;
error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Start:'.$query['start'].' NumRows:'.$query['num_rows'].' Took:'.$endtime);
return $rowsFetched['messages'];
}
@ -1180,4 +1209,18 @@ error_log(__METHOD__.__LINE__.array2string($query));
return $rv;
}
/**
* empty trash folder - its called via json, so the function must start with ajax (or the class-name must contain ajax)
*
* @return nothing
*/
function ajax_emptyTrash()
{
$trashFolder = $this->mail_bo->getTrashFolder();
if(!empty($trashFolder)) {
$this->mail_bo->compressFolder($trashFolder);
}
$response = egw_json_response::get();
$response->call('egw_refresh',lang('emptied Trash'),'mail');
}
}

28
mail/js/app.js Normal file
View File

@ -0,0 +1,28 @@
/**
* mail - static javaScript functions
*
* @link http://www.egroupware.org
* @author klaus leithoff <kl at stylite.de>
* @package mail
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
/**
* emptyTrash
*/
function emptyTrash() {
var request = new egw_json_request('mail.mail_ui.ajax_emptyTrash');
request.sendRequest();
}
/**
* changeFolder
*/
function changeFolder(folder,_widget) {
//alert('change Folder called:'+folder);
var nm = _widget.getRoot().getWidgetById('nm');
nm.activeFilters["selectedFolder"] = folder;
nm.applyFilters();
}

View File

@ -2,7 +2,7 @@
/**
* EGroupware - eTemplates for Application mail
* http://www.egroupware.org
* generated by soetemplate::dump4setup() 2013-02-12 15:25
* generated by soetemplate::dump4setup() 2013-02-12 17:52
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package mail
@ -12,7 +12,7 @@
$templ_version=1;
$templ_data[] = array('name' => 'mail.index','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:2:{i:0;a:3:{s:4:"type";s:4:"tree";s:4:"name";s:14:"nm[foldertree]";s:7:"onclick";s:39:"alert(\'on Changen node=\'+arguments[0]);";}i:1;a:3:{s:4:"type";s:9:"nextmatch";s:4:"name";s:2:"nm";s:4:"size";s:4:"rows";}}','size' => '100%,,,,0,3','style' => '','modified' => '1360577272',);
$templ_data[] = array('name' => 'mail.index','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:3:{i:0;a:3:{s:7:"onclick";s:42:"changeFolder(widget.event_args[0],widget);";s:4:"name";s:14:"nm[foldertree]";s:4:"type";s:4:"tree";}i:1;a:2:{s:4:"type";s:4:"html";s:4:"name";s:3:"msg";}i:2;a:3:{s:4:"name";s:2:"nm";s:4:"size";s:15:"mail.index.rows";s:4:"type";s:9:"nextmatch";}}','size' => '','style' => '','modified' => '1360682502',);
$templ_data[] = array('name' => 'mail.index.rows','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:6:{s:2:"c1";s:2:"th";s:1:"A";s:2:"25";s:1:"F";s:2:"50";s:1:"E";s:3:"120";s:1:"D";s:3:"120";s:1:"C";s:2:"95";}i:1;a:6:{s:1:"A";a:4:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:2:"ID";s:4:"name";s:3:"uid";s:8:"readonly";s:1:"1";}s:1:"B";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:4:"name";s:7:"subject";s:5:"label";s:7:"subject";}s:1:"C";a:4:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:4:"date";s:4:"name";s:4:"date";s:5:"align";s:6:"center";}s:1:"D";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:2:"to";s:4:"name";s:9:"toaddress";}s:1:"E";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:4:"from";s:4:"name";s:11:"fromaddress";}s:1:"F";a:4:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:4:"size";s:4:"name";s:4:"size";s:5:"align";s:6:"center";}}i:2;a:6:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"name";s:11:"${row}[uid]";s:8:"readonly";s:1:"1";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:4:"name";s:15:"${row}[subject]";}s:1:"C";a:4:{s:4:"type";s:9:"date-time";s:4:"name";s:12:"${row}[date]";s:8:"readonly";s:1:"1";s:5:"align";s:6:"center";}s:1:"D";a:3:{s:4:"type";s:9:"url-email";s:4:"name";s:17:"${row}[toaddress]";s:8:"readonly";s:1:"1";}s:1:"E";a:3:{s:4:"type";s:9:"url-email";s:4:"name";s:19:"${row}[fromaddress]";s:8:"readonly";s:1:"1";}s:1:"F";a:5:{s:4:"type";s:8:"vfs-size";s:4:"name";s:12:"${row}[size]";s:7:"no_lang";s:1:"1";s:8:"readonly";s:1:"1";s:5:"align";s:5:"right";}}}s:4:"rows";i:2;s:4:"cols";i:6;}}','size' => '','style' => '','modified' => '1360252030',);

View File

@ -32,7 +32,8 @@
</grid>
</template>
<template id="mail.index" template="" lang="" group="0" version="1.9.001">
<tree id="nm[foldertree]" onclick="alert('on Changen node='+arguments[0]);"/>
<tree id="nm[foldertree]" onclick="changeFolder(widget.event_args[0],widget);"/>
<html id="msg"/>
<nextmatch id="nm" options="mail.index.rows"/>
</template>
</overlay>