From 61bcdd2137bbe2d57685a1de3485153c99a4942a Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Fri, 18 Oct 2013 13:24:54 +0000 Subject: [PATCH] implement simple list signatures template based on grid widget --- mail/inc/class.mail_hooks.inc.php | 6 +- mail/inc/class.mail_signatures.inc.php | 107 +++++++++++++++++++- mail/templates/default/signatures.index.xet | 41 ++++++++ 3 files changed, 150 insertions(+), 4 deletions(-) create mode 100644 mail/templates/default/signatures.index.xet diff --git a/mail/inc/class.mail_hooks.inc.php b/mail/inc/class.mail_hooks.inc.php index 6656e4889c..5f99842945 100644 --- a/mail/inc/class.mail_hooks.inc.php +++ b/mail/inc/class.mail_hooks.inc.php @@ -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')); } diff --git a/mail/inc/class.mail_signatures.inc.php b/mail/inc/class.mail_signatures.inc.php index da77721a1f..9717561757 100644 --- a/mail/inc/class.mail_signatures.inc.php +++ b/mail/inc/class.mail_signatures.inc.php @@ -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'); diff --git a/mail/templates/default/signatures.index.xet b/mail/templates/default/signatures.index.xet new file mode 100644 index 0000000000..b61839e409 --- /dev/null +++ b/mail/templates/default/signatures.index.xet @@ -0,0 +1,41 @@ + + + + +