implement simple list signatures template based on grid widget

This commit is contained in:
Klaus Leithoff 2013-10-18 13:24:54 +00:00
parent eade0953b5
commit 61bcdd2137
3 changed files with 150 additions and 4 deletions

View File

@ -817,14 +817,14 @@ class mail_hooks
}
*/
if ($preferences->preferences['prefcontroltestconnection'] <> 'none') $file['Test Connection'] = egw::link('/index.php','menuaction=mail.mail_ui.TestConnection&appname=mail');
/*
if($preferences->ea_user_defined_signatures) {
$linkData = array (
'menuaction' => 'mail.uipreferences.listSignatures',
'menuaction' => 'mail.mail_signatures.index',
);
$file['Manage Signatures'] = egw::link('/index.php',$linkData);
}
/*
if(empty($preferences->preferences['prefpreventmanagefolders']) || $preferences->preferences['prefpreventmanagefolders'] == 0) {
$file['Manage Folders'] = egw::link('/index.php',array('menuaction'=>'mail.uipreferences.listFolder'));
}

View File

@ -9,9 +9,22 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
include_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.etemplate.inc.php');
class mail_signatures
{
var $public_functions = array
(
'index' => True,
);
/**
* nextMatch name for index
*
* @var string
*/
static $nm_index = 'sig';
var $tableName = 'egw_felamimail_signatures';
var $fm_signatureid = NULL;
@ -25,7 +38,12 @@ class mail_signatures
var $boemailadmin;
var $profileData;
function mail_signatures($_signatureID = NULL) {
/**
* Constructor
*
*/
function __construct($_signatureID = NULL)
{
$this->accountID = $GLOBALS['egw_info']['user']['account_id'];
if($_signatureID !== NULL) {
@ -35,6 +53,93 @@ class mail_signatures
$this->profileData = $this->boemailadmin->getUserProfile('felamimail');
}
/**
* Main signature list page
*
* @param array $content=null
* @param string $msg=null
*/
function index(array $content=null,$msg=null)
{
//Instantiate an etemplate_new object
$tmpl = new etemplate_new('mail.signatures.index');
if (!is_array($content))
{
$content['sig']= $this->get_rows($rows,$readonlys);
// Set content-menu actions
$tmpl->set_cell_attribute('sig', 'actions',$this->get_actions());
$sel_options = array(
'status' => array(
'ENABLED' => lang('Enabled'),
'DISABLED' => lang('Disabled'),
)
);
}
if ($msg)
{
$content['msg'] = $msg;
}
else
{
unset($msg);
unset($content['msg']);
}
$tmpl->exec('mail.mail_signatures.index',$content,$sel_options,$readonlys);
}
/**
* Get actions / context menu for index
*
* Changes here, require to log out, as $content[self::$nm_index] get stored in session!
* @var &$action_links
*
* @return array see nextmatch_widget::egw_actions()
*/
private function get_actions(array &$action_links=array())
{
$actions = array(
'open' => array(
'caption' => lang('Open'),
'icon' => 'view',
'group' => ++$group,
'onExecute' => 'javaScript:app.mail.mail_open',
'allowOnMultiple' => false,
'default' => true,
),
'delete' => array(
'caption' => lang('delete'),
'icon' => 'delete',
'group' => ++$group,
'onExecute' => 'javaScript:app.mail.mail_open',
'allowOnMultiple' => false,
),
);
return $actions;
}
/**
* Callback to fetch the rows for the nextmatch widget
*
* @param array $query
* @param array &$rows
* @param array &$readonlys
*/
function get_rows($query,&$rows)
{
$rows = $this->getListOfSignatures();
foreach ($rows as $i => &$row)
{
$row['row_id']='signature::'.($row['fm_accountid']?$row['fm_accountid']:$this->accountID).'::'.$row['fm_signatureid'];
$row['fm_defaultsignature'] = ($row['fm_defaultsignature']?'Default':'');
}
array_unshift($rows,array(''=> ''));
//_debug_array($rows);
return $rows;
}
function getDefaultSignature() {
$db = clone($GLOBALS['egw']->db);
$db->set_app('felamimail');

View File

@ -0,0 +1,41 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="mail.signatures.index.rows" template="" lang="" group="0" version="1.9.001">
<grid width="100%" id="sig" sortable="mail.mail_sieve.ajax_moveRule" class="egwGridView_grid">
<columns>
<column/>
<column/>
<column/>
</columns>
<rows>
<row class="th">
<description value="ID"/>
<description value="Description"/>
<description align="center" value="Default"/>
</row>
<row class="row" >
<description id="${row}[fm_signatureid]" readonly="true"/>
<description id="${row}[fm_description]" no_lang="1"/>
<description align="center" id="${row}[fm_defaultsignature]" no_lang="1" readonly="true"/>
</row>
</rows>
</grid>
</template>
<template id="mail.signatures.index" template="" lang="" group="0" version="1.9.001">
<description id="msg" no_lang="1" class="message" span="all"/>
<grid width="100%">
<columns>
<column width="100%"/>
</columns>
<rows>
<row>
<buttononly class="$cont[hideIfSigDisabled]" align="right" label="Add" id="add" onclick="window.open(egw::link('/index.php','menuaction=mail.mail_signatures.edit'),'_blank','dependent=yes,width=600,height=400,scrollbars=yes,status=yes'); return false;"/>
</row>
<row>
<template id="rows"/>
</row>
</rows>
</grid>
</template>
</overlay>