diff --git a/calendar/inc/class.bocalendar.inc.php b/calendar/inc/class.bocalendar.inc.php
index 9fa102b6fb..df05af6a26 100755
--- a/calendar/inc/class.bocalendar.inc.php
+++ b/calendar/inc/class.bocalendar.inc.php
@@ -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'].' ['.$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'])
diff --git a/calendar/inc/class.bocustom_fields.inc.php b/calendar/inc/class.bocustom_fields.inc.php
index 4c76ce1ee0..c3e7221344 100644
--- a/calendar/inc/class.bocustom_fields.inc.php
+++ b/calendar/inc/class.bocustom_fields.inc.php
@@ -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',
diff --git a/calendar/inc/class.socalendar_sql.inc.php b/calendar/inc/class.socalendar_sql.inc.php
index 85698be4ba..1718704bbb 100755
--- a/calendar/inc/class.socalendar_sql.inc.php
+++ b/calendar/inc/class.socalendar_sql.inc.php
@@ -451,7 +451,7 @@
function store_event()
{
- return $this->save_event(&$this->event);
+ return $this->save_event($this->event);
}
function delete_event($event_id)
diff --git a/calendar/inc/class.uicalendar.inc.php b/calendar/inc/class.uicalendar.inc.php
index 9b11aba08e..5cd18135d8 100755
--- a/calendar/inc/class.uicalendar.inc.php
+++ b/calendar/inc/class.uicalendar.inc.php
@@ -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' => ''
);
+// 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 = '';
+ }
+ $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)
{