history for emailadmin, by Chr.Fueller

This commit is contained in:
Klaus Leithoff 2010-09-27 14:54:15 +00:00
parent c54935ac0d
commit d21560ed70
4 changed files with 255 additions and 11 deletions

View File

@ -258,7 +258,7 @@ class emailadmin_bo extends so_sql
var $imapClass; // holds the imap/pop3 class
var $smtpClass; // holds the smtp class
var $tracking; // holds the tracking object
function __construct($_profileID=-1,$_restoreSesssion=true)
{
@ -302,6 +302,34 @@ class emailadmin_bo extends so_sql
}
$this->smtpClass = new $class;
}
$this->tracking =& new emailadmin_tracking($this);
}
function delete($profileid=null)
{
if (empty($profileid)) return 0;
$deleted = parent::delete(array('ea_profile_id' => $profileid));
if (!is_array($profileid)) $profileid = (array)$profileid;
foreach ($profileid as $tk => $pid)
{
self::$sessionData['profile'][$pid] = array();
}
$GLOBALS['egw']->contenthistory->updateTimeStamp('emailadmin_profiles', $profileid, 'delete', time());
self::saveSessionData();
return $deleted;
}
function save()
{
$content = $this->data;
$old = $this->read($content);
$this->data = $content;
if (!($result = parent::save()))
{
$GLOBALS['egw']->contenthistory->updateTimeStamp('emailadmin_profiles', $this->data['ea_profile_id'], $old === false ? 'add' : 'modify', time());
$this->tracking->track($content,$old,null,false,null,true);
}
return $result;
}
function addAccount($_hookValues)

View File

@ -0,0 +1,214 @@
<?php
/**
* EMailAdmin - history
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package addressbook
* @copyright (c) 2007 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id: class.emailadmin_tracking.inc.php 29941 2010-04-22 15:39:32Z nathangray $
*/
/**
* EMailAdmin - tracking object
*/
class emailadmin_tracking extends bo_tracking
{
/**
* Application we are tracking (required!)
*
* @var string
*/
var $app = 'emailadmin';
/**
* Name of the id-field, used as id in the history log (required!)
*
* @var string
*/
var $id_field = 'ea_profile_id';
/**
* Name of the field with the creator id, if the creator of an entry should be notified
*
* @var string
*/
//var $creator_field = '';
/**
* Name of the field with the id(s) of assinged users, if they should be notified
*
* @var string
*/
//var $assigned_field = '';
/**
* Translate field-name to 2-char history status
*
* @var array
*/
var $field2history = array(
'ea_smtp_server' => 'ea_smtp_server',
'ea_smtp_type' => 'ea_smtp_type',
'ea_smtp_port' => 'ea_smtp_port',
'ea_smtp_auth' => 'ea_smtp_auth',
'ea_editforwardingaddress' => 'ea_editforwardingaddress',
'ea_smtp_ldap_server' => 'ea_smtp_ldap_server',
'ea_smtp_ldap_basedn' => 'ea_smtp_ldap_basedn',
'ea_smtp_ldap_admindn' => 'ea_smtp_ldap_admindn',
'ea_smtp_ldap_adminpw' => 'ea_smtp_ldap_adminpw',
'ea_smtp_ldap_use_default' => 'ea_smtp_ldap_use_default',
'ea_imap_server' => 'ea_imap_server',
'ea_imap_type' => 'ea_imap_type',
'ea_imap_port' => 'ea_imap_port',
'ea_imap_login_type' => 'ea_imap_login_type',
'ea_imap_tsl_auth' => 'ea_imap_tsl_auth',
'ea_imap_tsl_encryption' => 'ea_imap_tsl_encryption',
'ea_imap_enable_cyrus' => 'ea_imap_enable_cyrus',
'ea_imap_admin_user' => 'ea_imap_admin_user',
'ea_imap_admin_pw' => 'ea_imap_admin_pw',
'ea_imap_enable_sieve' => 'ea_imap_enable_sieve',
'ea_imap_sieve_server' => 'ea_imap_sieve_server',
'ea_imap_sieve_port' => 'ea_imap_sieve_port',
'ea_description' => 'ea_description',
'ea_default_domain' => 'ea_default_domain',
'ea_organisation_name' => 'ea_organisation_name',
'ea_user_defined_identities' => 'ea_user_defined_identities',
'ea_user_defined_accounts' => 'ea_user_defined_accounts',
'ea_imapoldcclient' => 'ea_imapoldcclient',
'ea_order' => 'ea_order',
'ea_appname' => 'ea_appname',
'ea_group' => 'ea_group',
'ea_user' => 'ea_user',
'ea_active' => 'ea_active',
'ea_smtp_auth_username' => 'ea_smtp_auth_username',
'ea_smtp_auth_password' => 'ea_smtp_auth_password',
'ea_user_defined_signatures' => 'ea_user_defined_signatures',
'ea_default_signature' => 'ea_default_signature',
'ea_imap_auth_username' => 'ea_imap_auth_username',
'ea_imap_auth_password' => 'ea_imap_auth_password',
'ea_stationery_active_templates' => 'ea_stationery_active_templates'
);
/**
* Translate field name to label
*/
public $field2label = array(
'ea_smtp_server' => 'SMTP server',
'ea_smtp_type' => 'SMTP type',
'ea_smtp_port' => 'SMTP port',
'ea_smtp_auth' => 'SMTP authentification',
'ea_editforwardingaddress' => '',
'ea_smtp_ldap_server' => 'SMTP Ldap Server',
'ea_smtp_ldap_basedn' => '',
'ea_smtp_ldap_admindn' => '',
'ea_smtp_ldap_adminpw' => 'SMTP Ldap admin password',
'ea_smtp_ldap_use_default' => 'SMTP Ldap use default',
'ea_imap_server' => 'IMAP server',
'ea_imap_type' => 'IMAP type',
'ea_imap_port' => 'IMAP port',
'ea_imap_login_type' => 'IMAP login type',
'ea_imap_tsl_auth' => 'IMAP Tsl authentification',
'ea_imap_tsl_encryption' => 'IMAP Tsl encryption',
'ea_imap_enable_cyrus' => 'IMAP enable Cyrus',
'ea_imap_admin_user' => 'IMAP admin user',
'ea_imap_admin_pw' => 'IMAP admin password',
'ea_imap_enable_sieve' => 'IMAP enable Sieve',
'ea_imap_sieve_server' => 'IMAP Sieve server',
'ea_imap_sieve_port' => 'IMAP Sieve port',
'ea_description' => 'Description',
'ea_default_domain' => 'Default domain',
'ea_organisation_name' => 'Organisation',
'ea_user_defined_identities' => 'User defined identities',
'ea_user_defined_accounts' => 'User defined accounts',
'ea_imapoldcclient' => 'IMAP old client',
'ea_order' => 'Order',
'ea_appname' => 'Application',
'ea_group' => 'Group',
'ea_user' => 'User',
'ea_active' => 'Active',
'ea_smtp_auth_username' => 'SMTP authentification user',
'ea_smtp_auth_password' => 'SMTP authentification password',
'ea_user_defined_signatures' => 'User defined signatures',
'ea_default_signature' => 'Default signature',
'ea_imap_auth_username' => 'IMAP authentification user',
'ea_imap_auth_password' => 'IMAP authentification password',
'ea_stationery_active_templates' => ''
);
/**
* Should the user (passed to the track method or current user if not passed) be used as sender or get_config('sender')
*
* @var boolean
*/
var $prefer_user_as_sender = false;
/**
* Instance of the emailadmin_bo class calling us
*
* @access private
* @var emailadmin_bo
*/
var $emailadmin_bo;
/**
* Constructor
*
* @param emailadmin_bo &$emailadmin_bo
* @return tracker_tracking
*/
function __construct(&$emailadmin_bo)
{
parent::__construct(); // calling the constructor of the extended class
$this->emailadmin_bo =& $emailadmin_bo;
}
/**
* Get a notification-config value
*
* @param string $what
* - 'copy' array of email addresses notifications should be copied too, can depend on $data
* - 'lang' string lang code for copy mail
* - 'sender' string send email address
* @param array $data current entry
* @param array $old=null old/last state of the entry or null for a new entry
* @return mixed
*/
function get_config($name,$data,$old=null)
{
return null;
}
/**
* Get the modified / new message (1. line of mail body) for a given entry, can be reimplemented
*
* @param array $data
* @param array $old
* @return string
*/
function get_message($data,$old)
{
return null;
}
/**
* Get the subject of the notification
*
* @param array $data
* @param array $old
* @return string
*/
function get_subject($data,$old)
{
return null;
}
/**
* Get the details of an entry
*
* @param array $data
*
* @return array of details as array with values for keys 'label','value','type'
*/
function get_details($data)
{
return null;
}
}

View File

@ -381,6 +381,15 @@ class emailadmin_ui extends emailadmin_bo
// Stationery settings
$bostationery = new felamimail_bostationery();
$sel_options['ea_stationery_active_templates'] = $bostationery->get_stored_templates();
// setup history
$content['history'] = array(
'id' => $content['ea_profile_id'],
'app' => 'emailadmin'
);
//_debug_array($content);
foreach($this->tracking->field2label as $field => $label) {
$sel_options['status'][$field] = lang($label);
}
/*
$content['stored_templates'] = html::checkbox_multiselect(
'ea_stationery_active_templates',$content['ea_stationery_active_templates']
@ -407,14 +416,7 @@ class emailadmin_ui extends emailadmin_bo
{
$_profileID = ($profileid ? $profileid : (int)$_GET['profileid']);
if (empty($_profileID)) return 0;
$deleted = parent::delete(array('ea_profile_id' => $_profileID));
if (!is_array($_profileID)) $_profileID = (array)$_profileID;
foreach ($_profileID as $tk => $pid)
{
parent::$sessionData['profile'][$pid] = array();
}
parent::saveSessionData();
return $deleted;
return parent::delete($_profileID);
}
function listProfiles()

View File

@ -2,7 +2,7 @@
/**
* eGroupWare - eTemplates for Application emailadmin
* http://www.egroupware.org
* generated by soetemplate::dump4setup() 2010-06-23 14:43
* generated by soetemplate::dump4setup() 2010-09-07 15:19
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package emailadmin
@ -16,7 +16,7 @@ $templ_data[] = array('name' => 'emailadmin.edit','template' => '','lang' => '',
$templ_data[] = array('name' => 'emailadmin.edit.global','template' => '','lang' => '','group' => '0','version' => '1.7.003','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:4:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:4:{s:4:"type";s:8:"groupbox";s:5:"label";s:12:"Organisation";s:4:"size";s:1:"1";i:1;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:50:"enter your default mail domain (from: user@domain)";}s:1:"B";a:2:{s:4:"type";s:4:"text";s:4:"name";s:17:"ea_default_domain";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:20:"name of organisation";}s:1:"B";a:2:{s:4:"type";s:4:"text";s:4:"name";s:20:"ea_organisation_name";}}}s:4:"rows";i:2;s:4:"cols";i:2;s:7:"options";a:0:{}}}}i:2;a:1:{s:1:"A";a:4:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"1";s:5:"label";s:21:"profile access rights";i:1;a:5:{s:4:"type";s:4:"grid";s:7:"options";a:0:{}s:4:"data";a:4:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:26:"can be used by application";}s:1:"B";a:3:{s:4:"type";s:6:"select";s:4:"name";s:10:"ea_appname";s:4:"size";s:15:"any application";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:20:"can be used by group";}s:1:"B";a:3:{s:4:"type";s:14:"select-account";s:4:"size";s:16:"any group,groups";s:4:"name";s:8:"ea_group";}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:19:"can be used by user";}s:1:"B";a:3:{s:4:"type";s:14:"select-account";s:4:"size";s:17:"any user,accounts";s:4:"name";s:7:"ea_user";}}}s:4:"rows";i:3;s:4:"cols";i:2;}}}i:3;a:1:{s:1:"A";a:4:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"1";s:5:"label";s:14:"global options";i:1;a:5:{s:4:"type";s:4:"grid";s:7:"options";a:0:{}s:4:"data";a:5:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:17:"profile is active";}s:1:"B";a:2:{s:4:"type";s:8:"checkbox";s:4:"name";s:9:"ea_active";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:37:"users can define their own identities";}s:1:"B";a:3:{s:4:"type";s:8:"checkbox";s:4:"name";s:26:"ea_user_defined_identities";s:4:"size";s:6:"yes,no";}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:40:"users can define their own emailaccounts";}s:1:"B";a:3:{s:4:"type";s:8:"checkbox";s:4:"name";s:24:"ea_user_defined_accounts";s:4:"size";s:6:"yes,no";}}i:4;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:5:"order";}s:1:"B";a:2:{s:4:"type";s:3:"int";s:4:"name";s:8:"ea_order";}}}s:4:"rows";i:4;s:4:"cols";i:2;}}}}s:4:"rows";i:3;s:4:"cols";i:1;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '','modified' => '1255426691',);
$templ_data[] = array('name' => 'emailadmin.edit.history','template' => '','lang' => '','group' => '0','version' => '','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:1;s:4:"cols";i:1;s:4:"size";s:17:"100%,400,,,,,auto";s:7:"options";a:3:{i:0;s:4:"100%";i:1;s:3:"400";i:6;s:4:"auto";}}}','size' => '100%,400,,,,,auto','style' => '','modified' => '1255591575',);
$templ_data[] = array('name' => 'emailadmin.edit.history','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:2:{s:4:"type";s:10:"historylog";s:4:"name";s:7:"history";}}}s:4:"rows";i:1;s:4:"cols";i:1;s:4:"size";s:17:"100%,400,,,,,auto";s:7:"options";a:3:{i:0;s:4:"100%";i:1;s:3:"400";i:6;s:4:"auto";}}}','size' => '100%,400,,,,,auto','style' => '','modified' => '1283865538',);
$templ_data[] = array('name' => 'emailadmin.edit.IMAP','template' => '','lang' => '','group' => '0','version' => '1.7.005','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:7:{i:0;a:3:{s:2:"h3";s:27:",!@ea_imap_login_type=admin";s:2:"h5";s:27:",!@imapcapabilities=/sieve/";s:2:"h6";s:27:",!@imapcapabilities=/admin/";}i:1;a:1:{s:1:"A";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:2:{s:4:"type";s:5:"label";s:5:"label";s:26:"select type of IMAP server";}i:2;a:4:{s:4:"type";s:6:"select";s:4:"name";s:12:"ea_imap_type";s:5:"align";s:5:"right";s:8:"onchange";i:1;}}}i:2;a:1:{s:1:"A";a:4:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"1";s:5:"label";s:15:"server settings";i:1;a:5:{s:4:"type";s:4:"grid";s:7:"options";a:0:{}s:4:"data";a:4:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:34:"IMAP server hostname or ip address";}s:1:"B";a:2:{s:4:"type";s:4:"text";s:4:"name";s:14:"ea_imap_server";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:16:"IMAP server port";}s:1:"B";a:2:{s:4:"type";s:3:"int";s:4:"name";s:12:"ea_imap_port";}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:20:"imap server logintyp";}s:1:"B";a:3:{s:4:"type";s:6:"select";s:4:"name";s:18:"ea_imap_login_type";s:8:"onchange";i:1;}}}s:4:"rows";i:3;s:4:"cols";i:2;}}}i:3;a:1:{s:1:"A";a:3:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"1";i:1;a:5:{s:4:"type";s:4:"grid";s:7:"options";a:0:{}s:4:"data";a:4:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:1:"2";s:5:"label";s:42:"Use predefined username and password below";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:8:"username";}s:1:"B";a:2:{s:4:"type";s:4:"text";s:4:"name";s:21:"ea_imap_auth_username";}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:8:"password";}s:1:"B";a:2:{s:4:"type";s:6:"passwd";s:4:"name";s:21:"ea_imap_auth_password";}}}s:4:"rows";i:3;s:4:"cols";i:2;}}}i:4;a:1:{s:1:"A";a:4:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"1";s:5:"label";s:19:"encryption settings";i:1;a:5:{s:4:"type";s:4:"grid";s:7:"options";a:0:{}s:4:"data";a:3:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:20:"encrypted connection";}s:1:"B";a:6:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"4";i:1;a:4:{s:4:"type";s:5:"radio";s:4:"size";s:1:"1";s:5:"label";s:8:"STARTTLS";s:4:"name";s:22:"ea_imap_tsl_encryption";}i:2;a:4:{s:4:"type";s:5:"radio";s:4:"name";s:22:"ea_imap_tsl_encryption";s:4:"size";s:1:"2";s:5:"label";s:3:"TLS";}i:3;a:4:{s:4:"type";s:5:"radio";s:4:"name";s:22:"ea_imap_tsl_encryption";s:4:"size";s:1:"3";s:5:"label";s:3:"SSL";}i:4;a:4:{s:4:"type";s:5:"radio";s:4:"name";s:22:"ea_imap_tsl_encryption";s:4:"size";s:1:"0";s:5:"label";s:13:"no encryption";}}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:27:"do not validate certificate";}s:1:"B";a:3:{s:4:"type";s:8:"checkbox";s:4:"name";s:16:"ea_imap_tsl_auth";s:4:"size";s:6:"yes,no";}}}s:4:"rows";i:2;s:4:"cols";i:2;}}}i:5;a:1:{s:1:"A";a:4:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"1";s:5:"label";s:14:"sieve settings";i:1;a:5:{s:4:"type";s:4:"grid";s:7:"options";a:0:{}s:4:"data";a:5:{i:0;a:1:{s:2:"h1";s:2:",1";}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:26:"Sieve server or ip address";}s:1:"B";a:2:{s:4:"type";s:4:"text";s:4:"name";s:20:"ea_imap_sieve_server";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:12:"enable Sieve";}s:1:"B";a:3:{s:4:"type";s:8:"checkbox";s:4:"name";s:20:"ea_imap_enable_sieve";s:4:"size";s:6:"yes,no";}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:17:"Sieve server port";}s:1:"B";a:2:{s:4:"type";s:3:"int";s:4:"name";s:18:"ea_imap_sieve_port";}}i:4;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:1:"2";s:5:"label";s:78:"Vacation messages with start- and end-date require an admin account to be set";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:4;s:4:"cols";i:2;}}}i:6;a:1:{s:1:"A";a:4:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"1";s:5:"label";s:32:"Cyrus IMAP server administration";i:1;a:5:{s:4:"type";s:4:"grid";s:7:"options";a:0:{}s:4:"data";a:4:{i:0;a:2:{s:2:"h2";s:27:",!@ea_imap_enable_cyrus=yes";s:2:"h3";s:27:",!@ea_imap_enable_cyrus=yes";}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:39:"enable Cyrus IMAP server administration";}s:1:"B";a:4:{s:4:"type";s:8:"checkbox";s:4:"size";s:6:"yes,no";s:4:"name";s:20:"ea_imap_enable_cyrus";s:8:"onchange";i:1;}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:14:"admin username";}s:1:"B";a:2:{s:4:"type";s:4:"text";s:4:"name";s:18:"ea_imap_admin_user";}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:14:"admin password";}s:1:"B";a:2:{s:4:"type";s:6:"passwd";s:4:"name";s:16:"ea_imap_admin_pw";}}}s:4:"rows";i:3;s:4:"cols";i:2;}}}}s:4:"rows";i:6;s:4:"cols";i:1;s:4:"size";s:17:"100%,400,,,,,auto";s:7:"options";a:3:{i:0;s:4:"100%";i:1;s:3:"400";i:6;s:4:"auto";}}}','size' => '100%,400,,,,,auto','style' => '','modified' => '1274773039',);