Implement custom notification messages for infolog

This commit is contained in:
Nathan Gray 2013-01-30 23:12:52 +00:00
parent b272fb2cf5
commit ede9d83142
5 changed files with 139 additions and 3 deletions

View File

@ -16,7 +16,8 @@
class infolog_customfields
{
var $public_functions = array(
'edit' => True
'edit' => True,
'custom_notifications' => true
);
/**
* Instance of the infolog BO class
@ -371,4 +372,68 @@ class infolog_customfields
config::save_value('customfields',$this->fields,'infolog');
config::save_value('group_owners',$this->group_owners,'infolog');
}
/**
* Edit custom notifications for all infolog types and each type
*/
public function custom_notifications(Array $content = array())
{
$GLOBALS['egw_info']['flags']['app_header'] = lang('InfoLog').' - '.lang('Custom notifications');
if (is_array($content))
{
//echo '<pre style="text-align: left;">'; print_r($content); echo "</pre>\n";
list($action) = @each($content['button']);
switch($action)
{
case 'save':
case 'apply':
$notifications = array();
foreach($content['notification'] as $type)
{
if(trim($type['value']))
{
$notifications[$type['old_name']] = trim($type['value']);
}
}
config::save_value('custom_notification', $notifications,'infolog');
if ($action != 'save')
{
break;
}
case 'cancel':
$GLOBALS['egw']->redirect_link('/admin/');
exit;
}
}
else
{
$content = array();
}
$readonlys = array();
$config = config::read('infolog');
$n = 0;
$content['notification'][++$n] = array(
'name' => "~global~",
'value' => $config['custom_notification']['~global~'],
'label' => 'all',
'disabled' => False
);
$preserve['notification'][$n]['old_name'] = '~global~';
foreach($this->types as $type => $label)
{
$content['notification'][++$n] = array(
'value' => $config['custom_notification'][$type],
'label' => $label,
'disabled' => False
);
$preserve['notification'][$n]['old_name'] = $type;
}
//echo '<p>'.__METHOD__'.(content = <pre style="text-align: left;">'; print_r($content); echo "</pre>\n";
//echo 'readonlys = <pre style="text-align: left;">'; print_r($readonlys); echo "</pre>\n";
$this->tmpl->read('infolog.custom_notification');
$this->tmpl->exec('infolog.infolog_customfields.custom_notifications',$content,array(),$readonlys,$preserve);
}
}

View File

@ -123,7 +123,10 @@ class infolog_hooks
'appname' => $appname,
'global_cats'=> True)),
'Custom fields, typ and status' => egw::link('/index.php',array(
'menuaction' => 'infolog.infolog_customfields.edit'))
'menuaction' => 'infolog.infolog_customfields.edit')),
'Custom notifications' => egw::link('/index.php',array(
'menuaction' => 'infolog.infolog_customfields.custom_notifications'
)),
);
if ($location == 'admin')
{

View File

@ -321,6 +321,22 @@ class infolog_tracking extends bo_tracking
$config = array_merge($config,preg_split('/, ?/',$data['info_cc']));
}
break;
case self::CUSTOM_NOTIFICATION:
$info_config = config::read('infolog');
if(!$info_config[self::CUSTOM_NOTIFICATION])
{
return '';
}
// Per-type notification
elseif($info_config[self::CUSTOM_NOTIFICATION][$data['info_type']])
{
$config = $info_config[self::CUSTOM_NOTIFICATION][$data['info_type']];
}
else
{
$config = $info_config[self::CUSTOM_NOTIFICATION]['~global~'];
}
break;
}
return $config;
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,47 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="infolog.custom_notification" template="" lang="" group="0" version="1.9.001">
<grid>
<columns>
<column/>
</columns>
<rows>
<row>
<description id="msg" span="all" class="message"/>
</row>
<row>
<grid width="100%" id="notification">
<columns>
<column/>
<column/>
</columns>
<rows>
<row class="th">
<description value="Type"/>
<description value="Notification"/>
</row>
<row>
<description id="${row}[label]"/>
<textbox multiline="true" id="${row}[value]"/>
</row>
</rows>
</grid>
</row>
<row>
<hbox>
<button label="Save" id="button[save]"/>
<button label="Apply" id="button[apply]"/>
<button align="right" label="Cancel" id="button[cancel]"/>
</hbox>
</row>
</rows>
</grid>
<styles>
textarea {
min-width: 100em;
min-height: 5em;
}
</styles>
</template>
</overlay>