diff --git a/calendar/inc/class.socalendar_sql.inc.php b/calendar/inc/class.socalendar_sql.inc.php index 1718704bbb..479be4caa7 100755 --- a/calendar/inc/class.socalendar_sql.inc.php +++ b/calendar/inc/class.socalendar_sql.inc.php @@ -563,6 +563,15 @@ return $retval; } + function generate_uid($event) + { + if (!$event['id']) return False; // we need the id !!! + + $suffix = $GLOBALS['phpgw_info']['server']['hostname'] ? $GLOBALS['phpgw_info']['server']['hostname'] : 'local'; + $prefix = 'cal-'.$event['id'].'-'.$GLOBALS['phpgw_info']['server']['install_id']; + return $prefix . '@' . $suffix; + } + function save_event(&$event) { $locks = Array( @@ -575,38 +584,12 @@ $this->stream->lock($locks); if($event['id'] == 0) { - if(!$event['uid']) - { - if ($GLOBALS['phpgw_info']['server']['hostname'] != '') - { - $id_suffix = $GLOBALS['phpgw_info']['server']['hostname']; - } - else - { - $id_suffix = $GLOBALS['phpgw']->common->randomstring(3).'local'; - } - $parts = Array( - 0 => 'title', - 1 => 'description' - ); - @reset($parts); - while(list($key,$field) = each($parts)) - { - $part[$key] = substr($GLOBALS['phpgw']->crypto->encrypt($event[$field]),0,20); - if(!$GLOBALS['phpgw']->crypto->enabled) - { - $part[$key] = bin2hex(unserialize($part[$key])); - } - } - $event['uid'] = $part[0].'-'.$part[1].'@'.$id_suffix; - } - $this->stream->query('INSERT INTO phpgw_cal(uid,title,owner,priority,is_public,category) ' - . "values('".$event['uid']."','".$this->stream->db_addslashes($event['title']) + $this->stream->query('INSERT INTO phpgw_cal(title,owner,priority,is_public,category) ' + . "values('".$this->stream->db_addslashes($event['title']) . "',".(int)$event['owner'].','.(int)$event['priority'].','.(int)$event['public'].",'" . $event['category']."')",__LINE__,__FILE__); $event['id'] = $this->stream->get_last_insert_id('phpgw_cal','cal_id'); } - $date = $this->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; $enddate = $this->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; $today = time() - $GLOBALS['phpgw']->datetime->tz_offset; @@ -620,7 +603,13 @@ $type = 'E'; } + // new event or new created referencing event + if (!$event['uid'] || $event['reference'] && strstr($event['uid'],'cal-'.$event['reference'].'-')) + { + $event['uid'] = $this->generate_uid($event); + } $sql = 'UPDATE phpgw_cal SET ' + . 'uid='.$this->stream->quote($event['uid']).',' . 'owner='.(int)$event['owner'].', ' . 'datetime='.(int)$date.', ' . 'mdatetime='.(int)$today.', ' diff --git a/calendar/setup/setup.inc.php b/calendar/setup/setup.inc.php index c2efcc5581..f89574a4c5 100755 --- a/calendar/setup/setup.inc.php +++ b/calendar/setup/setup.inc.php @@ -12,7 +12,7 @@ /* $Id$ */ $setup_info['calendar']['name'] = 'calendar'; - $setup_info['calendar']['version'] = '0.9.16.005'; + $setup_info['calendar']['version'] = '0.9.16.006'; $setup_info['calendar']['app_order'] = 3; $setup_info['calendar']['enable'] = 1; @@ -21,7 +21,7 @@ $setup_info['calendar']['description'] = 'Powerful calendar with meeting request system and ACL security.'; $setup_info['calendar']['note'] = - 'Bassed on Webcalendar by Craig Knudsen.
+ 'Originaly based on Webcalendar by Craig Knudsen.
'; $setup_info['calendar']['maintainer'] = array( 'name' => 'Ralf Becker', diff --git a/calendar/setup/tables_update.inc.php b/calendar/setup/tables_update.inc.php index 431ad70073..ad0327536e 100644 --- a/calendar/setup/tables_update.inc.php +++ b/calendar/setup/tables_update.inc.php @@ -1030,4 +1030,24 @@ $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.16.005'; return $GLOBALS['setup_info']['calendar']['currentver']; } + + + $test[] = '0.9.16.005'; + function calendar_upgrade0_9_16_005() + { + // creates uid's for all entries which do not have unique ones, they are '-@domain.com' + $GLOBALS['phpgw_setup']->oProc->query("SELECT config_name,config_value FROM phpgw_config WHERE config_name IN ('install_id','mail_suffix') AND config_app='phpgwapi'",__LINE__,__FILE__); + while ($GLOBALS['phpgw_setup']->oProc->next_record()) + { + $config[$GLOBALS['phpgw_setup']->oProc->f(0)] = $GLOBALS['phpgw_setup']->oProc->f(1); + } + $GLOBALS['phpgw_setup']->oProc->query('UPDATE phpgw_cal SET uid='. + $GLOBALS['phpgw_setup']->db->concat($GLOBALS['phpgw_setup']->db->quote('cal-'),'cal_id', + $GLOBALS['phpgw_setup']->db->quote('-'.$config['install_id'].'@'. + ($config['mail_suffix'] ? $config['mail_suffix'] : 'local'))). + " WHERE uid LIKE '-@%'"); + + $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.16.006'; + return $GLOBALS['setup_info']['calendar']['currentver']; + } ?>