make projects linkable to calendar events

This commit is contained in:
Lars Kneschke 2004-05-06 00:59:47 +00:00
parent 7cf2d5ddaf
commit 6cba1832b9
4 changed files with 89 additions and 5 deletions

View File

@ -554,6 +554,7 @@
function read_entry($id,$ignore_acl=False)
{
$bolink = createObject('infolog.bolink');
if (is_array($id) && count($id) == 1)
{
list(,$id) = each($id);
@ -561,6 +562,19 @@
if($ignore_acl || $this->check_perms(PHPGW_ACL_READ,$id))
{
$event = $this->so->read_entry($id);
$linkIDs = $bolink->get_links('calendar', $id);
if(is_array($linkIDs))
{
foreach($linkIDs as $linkData)
{
//$event['projectID'] = 8;
if($linkData['app'] == 'projects')
{
$event['projectID'] = $linkData['id'];
continue;
}
}
}
if(!isset($event['participants'][$this->owner]) && $this->user_is_a_member($event,$this->owner))
{
$this->so->add_attribute('participants','U',(int)$this->owner);
@ -1103,6 +1117,15 @@
}
$date = sprintf("%04d%02d%02d",$event['start']['year'],$event['start']['month'],$event['start']['mday']);
if(isset($l_cal['project']))
{
$bolink = createObject('infolog.bolink');
$bolink->unlink(0,'calendar',$event['id']);
if($l_cal['project'] != 'no_project')
{
$bolink->link('calendar',$event['id'],'projects',$l_cal['project']);
}
}
if($send_to_ui)
{
$this->read_sessiondata();
@ -2006,6 +2029,7 @@
}
}
}
if(!$eyear && !$emonth && !$eday)
{
$edate = mktime(23,59,59,$smonth + 1,$sday + 1,$syear);
@ -2114,7 +2138,7 @@
}
}
}
$this->repeating_events = Array();
if($c_cached_ids_repeating)
{
@ -2144,6 +2168,7 @@
}
}
}
$retval = Array();
for($j=date('Ymd',mktime(0,0,0,$smonth,$sday,$syear)),$k=0;$j<=date('Ymd',mktime(0,0,0,$emonth,$eday,$eyear));$k++,$j=date('Ymd',mktime(0,0,0,$smonth,$sday + $k,$syear)))
{
@ -2965,6 +2990,8 @@
*/
function event2array($event)
{
$ownerApps = $GLOBALS['phpgw']->acl->get_user_applications($event['owner']);
$var['title'] = Array(
'field' => lang('Title'),
'data' => $event['title']
@ -3037,6 +3064,16 @@
'data' => $event['public'] ? lang('Public') : lang('Private')
);
if($ownerApps['projects'] && $event['projectID'])
{
$boprojects = createObject('projects.boprojects');
$projectData = $boprojects->read_single_project($event['projectID']);
$var['project'] = Array
(
'field' => lang('Project'),
'data' => $projectData['title'].'&nbsp;['.$projectData['number'].']'
);
}
if(@isset($event['groups'][0]))
{
$cal_grps = '';
@ -3120,6 +3157,10 @@
$this->fields = &$this->custom_fields->fields;
$this->stock_fields = &$this->custom_fields->stock_fields;
}
// projects
if($ownerApps['projects'])
$this->fields['project']['disabled'] = false;
foreach($this->fields as $field => $data)
{
if (!$data['disabled'])

View File

@ -22,6 +22,10 @@
'description' => 'Description',
'category' => 'Category',
'location' => 'Location',
'project' => array(
'label' => 'Project',
'disabled' => true,
),
'startdate' => 'Start Date/Time',
'enddate' => 'End Date/Time',
'priority' => 'Priority',

View File

@ -451,7 +451,7 @@
function store_event()
{
return $this->save_event(&$this->event);
return $this->save_event($this->event);
}
function delete_event($event_id)

View File

@ -541,7 +541,7 @@
$var = Array(
'printer_friendly' => $printer,
'bg_text' => $this->theme['bg_text'],
'bg_text' => $this->theme['bg_text'],
'small_calendar_prev' => $minical_prev,
'prev_week_link' => $prev_week_link,
'small_calendar_this' => $minical_this,
@ -2088,7 +2088,7 @@
)
);
$this->bo->remove_doubles_in_cache($this->planner_firstday,$this->planner_lastday);
// process all events within observed interval
//
for($v=$this->planner_firstday;$v<=$this->planner_lastday;$v++)
@ -3795,7 +3795,9 @@
$GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
$GLOBALS['phpgw_info']['flags']['app_header'] = $event['id'] ? lang('Calendar - Edit') : lang('Calendar - Add');
$GLOBALS['phpgw']->common->phpgw_header();
$ownerApps = $GLOBALS['phpgw']->acl->get_user_applications($event['owner']);
$p = &$GLOBALS['phpgw']->template;
$p->set_file(
Array(
@ -3865,6 +3867,37 @@
'data' => '<input name="cal[location]" size="45" maxlength="255" value="'.$event['location'].'">'
);
// Project
if($ownerApps['projects'])
{
$boprojects = createObject('projects.boprojects');
$projects = $boprojects->list_projects( array('limit'=>FALSE) );
$projectOptions = $boprojects->select_project_list
(
array
(
'action' => 'all',
'status' => 'active',
'selected' => $event['projectID']
)
);
if(is_array($projects))
{
$projectData = '<select name="cal[project]">';
if(!isset($event['projectID']))
$projectData .= '<option value="no_project" selected="selected"></option>';
else
$projectData .= '<option value="no_project"></option>';
$projectData .= $projectOptions;
$projectData .= '</select>';
}
$var['project'] = Array(
'field' => lang('Project'),
'data' => $projectData
);
}
// Date
$start = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
@ -4147,6 +4180,12 @@
$this->fields = &$this->custom_fields->fields;
$this->stock_fields = &$this->custom_fields->stock_fields;
}
$ownerApps = $GLOBALS['phpgw']->acl->get_user_applications($event['owner']);
if($ownerApps['projects'])
{
// enable project app
$this->fields['project']['disabled'] = false;
}
$preserved = False;
foreach($this->fields as $field => $data)
{