mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:38 +01:00
Placeholder dialog: Add placeholders for projectmanager, timesheet, tracker
This commit is contained in:
parent
66cf807cdd
commit
a0a89a6b74
@ -93,6 +93,15 @@ class Placeholder extends Etemplate\Widget
|
||||
{
|
||||
$list = array_intersect_key($list, $group);
|
||||
}
|
||||
// Remove if empty
|
||||
foreach($list as $p_group => $p_list)
|
||||
{
|
||||
if(count($p_list) == 0)
|
||||
{
|
||||
unset($list[$p_group]);
|
||||
}
|
||||
}
|
||||
|
||||
if($list)
|
||||
{
|
||||
$placeholders[$appname] = $list;
|
||||
|
@ -968,10 +968,10 @@ abstract class Merge
|
||||
}
|
||||
if ($this->report_memory_usage) error_log(__METHOD__."() $n: $id ".Api\Vfs::hsize(memory_get_usage(true)));
|
||||
// some general replacements: current user, date and time
|
||||
if (strpos($content,'$$user/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')))
|
||||
if(strpos($content, '$$user/') !== false && ($user = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id')))
|
||||
{
|
||||
$replacements += $this->contact_replacements($user,'user', false, $content);
|
||||
$replacements['$$user/primary_group$$'] = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'account_primary_group'));
|
||||
$replacements += $this->contact_replacements($user, 'user', false, $content);
|
||||
$replacements['$$user/primary_group$$'] = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'account_primary_group'));
|
||||
}
|
||||
$replacements['$$date$$'] = Api\DateTime::to('now',true);
|
||||
$replacements['$$datetime$$'] = Api\DateTime::to('now');
|
||||
@ -2828,7 +2828,7 @@ abstract class Merge
|
||||
* Here we adjust the group name, and add the group to the end of the placeholder list
|
||||
* @param array $placeholder_list Our placeholder list
|
||||
* @param string $base_name Name of the entry (eg: Contact, custom field name)
|
||||
* @param array $add_placeholder_groups Placeholder list from the other app
|
||||
* @param array $add_placeholder_groups Placeholder list from the other app. Placeholders should include any needed prefix
|
||||
*/
|
||||
protected function add_linked_placeholders(&$placeholder_list, $base_name, $add_placeholder_groups) : void
|
||||
{
|
||||
|
@ -207,14 +207,59 @@ class timesheet_merge extends Api\Storage\Merge
|
||||
$i++;
|
||||
}
|
||||
|
||||
echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>";
|
||||
echo '<tr><td colspan="4"><h3>' . lang('General fields:') . "</h3></td></tr>";
|
||||
foreach($this->get_common_replacements() as $name => $label)
|
||||
{
|
||||
echo '<tr><td>{{'.$name.'}}</td><td colspan="3">'.$label."</td></tr>\n";
|
||||
echo '<tr><td>{{' . $name . '}}</td><td colspan="3">' . $label . "</td></tr>\n";
|
||||
}
|
||||
|
||||
echo "</table>\n";
|
||||
|
||||
echo $GLOBALS['egw']->framework->footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of placeholders provided.
|
||||
*
|
||||
* Placeholders are grouped logically. Group key should have a user-friendly translation.
|
||||
*/
|
||||
public function get_placeholder_list($prefix = '')
|
||||
{
|
||||
$placeholders = array(
|
||||
'timesheet' => [],
|
||||
lang('Project') => []
|
||||
) + parent::get_placeholder_list($prefix);
|
||||
|
||||
$fields = array('ts_id' => lang('Timesheet ID')) + $this->bo->field2label + array(
|
||||
'ts_total' => lang('total'),
|
||||
'ts_created' => lang('Created'),
|
||||
'ts_modified' => lang('Modified'),
|
||||
);
|
||||
$group = 'timesheet';
|
||||
foreach($fields as $name => $label)
|
||||
{
|
||||
if(in_array($name, array('custom')))
|
||||
{
|
||||
// dont show them
|
||||
continue;
|
||||
}
|
||||
$marker = $this->prefix($prefix, $name, '{');
|
||||
if(!array_filter($placeholders, function ($a) use ($marker)
|
||||
{
|
||||
return array_key_exists($marker, $a);
|
||||
}))
|
||||
{
|
||||
$placeholders[$group][] = [
|
||||
'value' => $marker,
|
||||
'label' => $label
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Add project placeholders
|
||||
$pm_merge = new projectmanager_merge();
|
||||
$this->add_linked_placeholders($placeholders, lang('Project'), $pm_merge->get_placeholder_list('ts_project'));
|
||||
|
||||
return $placeholders;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user