mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-13 17:38:19 +01:00
fixed some bugs in the document templates and added the ability to print the next appointments of a contact
This commit is contained in:
parent
cbc565c0ce
commit
28d9dbf471
@ -95,7 +95,7 @@ class addressbook_merge // extends bo_merge
|
|||||||
{
|
{
|
||||||
$cats[] = $GLOBALS['egw']->cats->id2name($cat_id);
|
$cats[] = $GLOBALS['egw']->cats->id2name($cat_id);
|
||||||
}
|
}
|
||||||
$value = explode(', ',$cats);
|
$value = implode(', ',$cats);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'jpegphoto': // returning a link might make more sense then the binary photo
|
case 'jpegphoto': // returning a link might make more sense then the binary photo
|
||||||
@ -112,8 +112,14 @@ class addressbook_merge // extends bo_merge
|
|||||||
$value = $contact[$value];
|
$value = $contact[$value];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'account_id':
|
||||||
|
if ($value)
|
||||||
|
{
|
||||||
|
$replacements['$$'.($prefix ? $prefix.'/':'').'account_lid$$'] = $GLOBALS['egw']->accounts->id2name($value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if ($name != 'photo') $replacements[($prefix ? $prefix.'[':'').'$$'.$name.'$$'.($prefix ? ']':'')] = $value;
|
if ($name != 'photo') $replacements['$$'.($prefix ? $prefix.'/':'').$name.'$$'] = $value;
|
||||||
}
|
}
|
||||||
return $replacements;
|
return $replacements;
|
||||||
}
|
}
|
||||||
@ -128,7 +134,42 @@ class addressbook_merge // extends bo_merge
|
|||||||
*/
|
*/
|
||||||
function calendar_replacements($id)
|
function calendar_replacements($id)
|
||||||
{
|
{
|
||||||
return array();
|
require_once(EGW_INCLUDE_ROOT.'/calendar/inc/class.bocalupdate.inc.php');
|
||||||
|
$calendar =& new bocalupdate();
|
||||||
|
|
||||||
|
$replacements = array(); $n = 1;
|
||||||
|
foreach($calendar->search(array(
|
||||||
|
'start' => $calendar->now_su,
|
||||||
|
'users' => 'c'.$id,
|
||||||
|
'offset' => 0,
|
||||||
|
'num_rows' => 20,
|
||||||
|
'order' => 'cal_start',
|
||||||
|
)) as $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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,17 +203,27 @@ class addressbook_merge // extends bo_merge
|
|||||||
$err = lang('Contact not found!');
|
$err = lang('Contact not found!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (strpos($content,'$$user[') !== null)
|
if (strpos($content,'$$user/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')))
|
||||||
{
|
{
|
||||||
$replacements += $this->contact_replacements('account_id:'.$GLOBALS['egw_info']['user']['account_id'],'user');
|
$replacements += $this->contact_replacements($user,'user');
|
||||||
}
|
}
|
||||||
if (strpos($content,'$$calendar[') !== null)
|
if (strpos($content,'$$calendar/') !== null)
|
||||||
{
|
{
|
||||||
$replacements += $this->calendar_replacements($id);
|
$replacements += $this->calendar_replacements($id);
|
||||||
}
|
}
|
||||||
$replacements['$$date$$'] = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'],time()+$this->contacts->tz_offset_s);
|
$replacements['$$date$$'] = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'],time()+$this->contacts->tz_offset_s);
|
||||||
|
|
||||||
return str_replace(array_keys($replacements),array_values($replacements),$content);
|
if ($this->contacts->prefs['csv_charset']) // if we have an export-charset defined, use it here to
|
||||||
|
{
|
||||||
|
$replacements = $GLOBALS['egw']->translation->convert($replacements,$GLOBALS['egw']->translation->charset(),$this->contacts->prefs['csv_charset']);
|
||||||
|
}
|
||||||
|
$content = str_replace(array_keys($replacements),array_values($replacements),$content);
|
||||||
|
|
||||||
|
if (strpos($content,'$$calendar/') !== null) // remove not existing event-replacements
|
||||||
|
{
|
||||||
|
$content = preg_replace('/\$\$calendar\/[0-9]+\/[a-z_]+\$\$/','',$content);
|
||||||
|
}
|
||||||
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -230,19 +281,42 @@ class addressbook_merge // extends bo_merge
|
|||||||
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(array(
|
foreach(array(
|
||||||
'date' => lang('Date'),
|
'date' => lang('Date'),
|
||||||
'user[n_fn]' => lang('Name of current user, all other contact fields are valid too'),
|
'user/n_fn' => lang('Name of current user, all other contact fields are valid too'),
|
||||||
'user[account_lid]' => lang('Username'),
|
'user/account_lid' => lang('Username'),
|
||||||
) as $name => $label)
|
) 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";
|
||||||
}
|
}
|
||||||
|
$GLOBALS['egw']->translation->add_app('calendar');
|
||||||
echo '<tr><td colspan="4"><h3>'.lang('Calendar fields:')."</h3></td></tr>";
|
echo '<tr><td colspan="4"><h3>'.lang('Calendar fields:')." # = 1, 2, ..., 20</h3></td></tr>";
|
||||||
foreach(array(
|
foreach(array(
|
||||||
|
'title' => lang('Title'),
|
||||||
|
'description' => lang('Description'),
|
||||||
|
'participants' => lang('Participants'),
|
||||||
|
'category' => 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'),
|
||||||
|
'owner' => lang('Owner'),
|
||||||
|
'priority' => lang('Priority'),
|
||||||
|
'updated' => lang('Updated'),
|
||||||
|
'recur_type' => lang('Repetition'),
|
||||||
|
'access' => lang('Access').': '.lang('public').', '.lang('private'),
|
||||||
) as $name => $label)
|
) 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>';
|
if (!($n&1)) echo '<tr>';
|
||||||
echo '<td>$$'.$name.'$$</td><td>'.$label.'</td>';
|
echo '<td>$$calendar/#/'.$name.'$$</td><td>'.$label.'</td>';
|
||||||
if ($n&1) echo "</tr>\n";
|
if ($n&1) echo "</tr>\n";
|
||||||
$n++;
|
$n++;
|
||||||
}
|
}
|
||||||
|
@ -791,8 +791,35 @@ class bocontacts extends socontacts
|
|||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'type' => 'c',// one char type-identifiy for this resources
|
'type' => 'c',// one char type-identifiy for this resources
|
||||||
|
'info' => 'addressbook.bocontacts.calendar_info',// info method, returns array with id, type & name for a given id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns info about contacts for calender
|
||||||
|
*
|
||||||
|
* @param int/array $ids single contact-id or array of id's
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function calendar_info($ids)
|
||||||
|
{
|
||||||
|
if (!$ids) return null;
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
foreach(!is_array($ids) ? array($ids) : $ids as $id)
|
||||||
|
{
|
||||||
|
if (!($contact = $this->read($id))) continue;
|
||||||
|
|
||||||
|
$data[] = array(
|
||||||
|
'res_id' => $id,
|
||||||
|
'email' => $contact['email'] ? $contact['email'] : $contact['email_home'],
|
||||||
|
'rights' => EGW_ACL_READ_FOR_PARTICIPANTS,
|
||||||
|
'name' => $this->link_title($contact),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
//echo "<p>calendar_info(".print_r($ids,true).")="; _debug_array($data);
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by delete-account hook, when an account get deleted --> deletes/moves the personal addressbook
|
* Called by delete-account hook, when an account get deleted --> deletes/moves the personal addressbook
|
||||||
|
@ -480,7 +480,7 @@ class uicontacts extends bocontacts
|
|||||||
}
|
}
|
||||||
if (substr($action,0,9) == 'document-')
|
if (substr($action,0,9) == 'document-')
|
||||||
{
|
{
|
||||||
$document = substr($action,10);
|
$document = substr($action,9);
|
||||||
$action = 'document';
|
$action = 'document';
|
||||||
}
|
}
|
||||||
// Security: stop non-admins to export more then the configured number of contacts
|
// Security: stop non-admins to export more then the configured number of contacts
|
||||||
|
Loading…
Reference in New Issue
Block a user