mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 07:53:39 +01:00
Remove unneeded calendar stuff, add contact expansion
This commit is contained in:
parent
6c580bb7f1
commit
ab54bf675f
@ -55,9 +55,13 @@ class infolog_merge extends bo_merge
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!(strpos($content,'$$calendar/') === false))
|
||||
if (!(strpos($content,'$$info_contact/') === false))
|
||||
{
|
||||
$replacements += $this->calendar_replacements($id,!(strpos($content,'$$calendar/-1/') === false));
|
||||
// Check to see if it's actually a contact, then load
|
||||
if(is_array($replacements['$$info_link$$']) && $replacements['$$info_link$$']['app'] == 'addressbook')
|
||||
{
|
||||
$replacements += $this->contact_replacements($replacements['$$info_link$$']['id'],'info_contact');
|
||||
}
|
||||
}
|
||||
return $replacements;
|
||||
}
|
||||
@ -95,80 +99,14 @@ class infolog_merge extends bo_merge
|
||||
}
|
||||
|
||||
// Add markers
|
||||
foreach($array as $key => $value)
|
||||
foreach($array as $key => &$value)
|
||||
{
|
||||
if(!$value) $value = '';
|
||||
$info['$$'.($prefix ? $prefix.'/':'').$key.'$$'] = $value;
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return replacements for the calendar (next events) of a contact
|
||||
*
|
||||
* @param int $contact contact-id
|
||||
* @param boolean $last_event_too=false also include information about the last event
|
||||
* @return array
|
||||
*/
|
||||
protected function calendar_replacements($id,$last_event_too=false)
|
||||
{
|
||||
$calendar = new calendar_boupdate();
|
||||
|
||||
// next events
|
||||
$events = $calendar->search(array(
|
||||
'start' => $calendar->now_su,
|
||||
'users' => 'c'.$id,
|
||||
'offset' => 0,
|
||||
'num_rows' => 20,
|
||||
'order' => 'cal_start',
|
||||
));
|
||||
if ($events)
|
||||
{
|
||||
array_unshift($events,false); unset($events[0]); // renumber the array to start with key 1, instead of 0
|
||||
}
|
||||
else
|
||||
{
|
||||
$events = array();
|
||||
}
|
||||
if ($last_event_too=true)
|
||||
{
|
||||
$last = $calendar->search(array(
|
||||
'end' => $calendar->now_su,
|
||||
'users' => 'c'.$id,
|
||||
'offset' => 0,
|
||||
'num_rows' => 1,
|
||||
'order' => 'cal_start DESC',
|
||||
));
|
||||
if ($last) $events['-1'] = array_shift($last); // returned events are indexed by cal_id!
|
||||
}
|
||||
$replacements = array();
|
||||
foreach($events as $n => $event)
|
||||
{
|
||||
foreach($calendar->event2array($event) as $name => $data)
|
||||
{
|
||||
if (substr($name,-4) == 'date') $name = substr($name,0,-4);
|
||||
$replacements['$$calendar/'.$n.'/'.$name.'$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data'];
|
||||
}
|
||||
foreach(array('start','end') as $what)
|
||||
{
|
||||
foreach(array(
|
||||
'date' => $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'],
|
||||
'day' => 'l',
|
||||
'time' => $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i',
|
||||
) as $name => $format)
|
||||
{
|
||||
$value = date($format,$event[$what]);
|
||||
if ($format == 'l') $value = lang($value);
|
||||
$replacements['$$calendar/'.$n.'/'.$what.$name.'$$'] = $value;
|
||||
}
|
||||
}
|
||||
$duration = ($event['end'] - $event['start'])/60;
|
||||
$replacements['$$calendar/'.$n.'/duration$$'] = floor($duration/60).lang('h').($duration%60 ? $duration%60 : '');
|
||||
|
||||
++$n;
|
||||
}
|
||||
return $replacements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate table with replacements for the preferences
|
||||
*
|
||||
@ -184,7 +122,8 @@ class infolog_merge extends bo_merge
|
||||
|
||||
$n = 0;
|
||||
$tracking = new infolog_tracking($this->bo);
|
||||
foreach($tracking->field2label as $name => $label)
|
||||
$fields = array('info_id' => lang('Infolog ID')) + $tracking->field2label;
|
||||
foreach($fields as $name => $label)
|
||||
{
|
||||
if (in_array($name,array('custom'))) continue; // dont show them
|
||||
|
||||
@ -205,6 +144,29 @@ class infolog_merge extends bo_merge
|
||||
echo '<tr><td>$$#'.$name.'$$</td><td colspan="3">'.$field['label']."</td></tr>\n";
|
||||
}
|
||||
|
||||
echo '<tr><td colspan="4"><h3>'.lang('Contact fields').':</h3></td></tr>';
|
||||
$n = 0;
|
||||
foreach($this->contacts->contact_fields as $name => $label)
|
||||
{
|
||||
if (in_array($name,array('tid','label','geo'))) continue; // dont show them, as they are not used in the UI atm.
|
||||
|
||||
if (in_array($name,array('email','org_name','tel_work','url')) && $n&1) // main values, which should be in the first column
|
||||
{
|
||||
echo "</tr>\n";
|
||||
$n++;
|
||||
}
|
||||
if (!($n&1)) echo '<tr>';
|
||||
echo '<td>$$info_contact/'.$name.'$$</td><td>'.$label.'</td>';
|
||||
if ($n&1) echo "</tr>\n";
|
||||
$n++;
|
||||
}
|
||||
|
||||
echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>";
|
||||
foreach($this->contacts->customfields as $name => $field)
|
||||
{
|
||||
echo '<tr><td>$$info_contact/#'.$name.'$$</td><td colspan="3">'.$field['label']."</td></tr>\n";
|
||||
}
|
||||
|
||||
echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>";
|
||||
foreach(array(
|
||||
'date' => lang('Date'),
|
||||
@ -223,40 +185,6 @@ class infolog_merge extends bo_merge
|
||||
echo '<tr><td>$$'.$name.'$$</td><td colspan="3">'.$label."</td></tr>\n";
|
||||
}
|
||||
|
||||
$GLOBALS['egw']->translation->add_app('calendar');
|
||||
echo '<tr><td colspan="4"><h3>'.lang('Calendar fields:')." # = 1, 2, ..., 20, -1</h3></td></tr>";
|
||||
foreach(array(
|
||||
'title' => lang('Title'),
|
||||
'description' => lang('Description'),
|
||||
'participants' => lang('Participants'),
|
||||
'location' => lang('Location'),
|
||||
'start' => lang('Start').': '.lang('Date').'+'.lang('Time'),
|
||||
'startday' => lang('Start').': '.lang('Weekday'),
|
||||
'startdate'=> lang('Start').': '.lang('Date'),
|
||||
'starttime'=> lang('Start').': '.lang('Time'),
|
||||
'end' => lang('End').': '.lang('Date').'+'.lang('Time'),
|
||||
'endday' => lang('End').': '.lang('Weekday'),
|
||||
'enddate' => lang('End').': '.lang('Date'),
|
||||
'endtime' => lang('End').': '.lang('Time'),
|
||||
'duration' => lang('Duration'),
|
||||
'category' => lang('Category'),
|
||||
'priority' => lang('Priority'),
|
||||
'updated' => lang('Updated'),
|
||||
'recur_type' => lang('Repetition'),
|
||||
'access' => lang('Access').': '.lang('public').', '.lang('private'),
|
||||
'owner' => lang('Owner'),
|
||||
) as $name => $label)
|
||||
{
|
||||
if (in_array($name,array('start','end')) && $n&1) // main values, which should be in the first column
|
||||
{
|
||||
echo "</tr>\n";
|
||||
$n++;
|
||||
}
|
||||
if (!($n&1)) echo '<tr>';
|
||||
echo '<td>$$calendar/#/'.$name.'$$</td><td>'.$label.'</td>';
|
||||
if ($n&1) echo "</tr>\n";
|
||||
$n++;
|
||||
}
|
||||
echo "</table>\n";
|
||||
|
||||
common::egw_footer();
|
||||
|
Loading…
Reference in New Issue
Block a user