fix for bug [ 871421 ] CSV import not functioning

This commit is contained in:
Ralf Becker 2004-04-01 18:03:02 +00:00
parent 67375d4da1
commit 313811809d

View File

@ -171,8 +171,8 @@
'title' => 'Title varchar(80)', 'title' => 'Title varchar(80)',
'description' => 'Description text', 'description' => 'Description text',
'location' => 'Location varchar(255)', 'location' => 'Location varchar(255)',
'start' => 'Start Date: start: Timestamp or eg. YYYY-MM-DD hh:mm', 'start' => 'Start Date: Timestamp or eg. YYYY-MM-DD hh:mm',
'end' => 'End Date: start', 'end' => 'End Date: Timestamp or eg. YYYY-MM-DD hh:mm',
'participants' => 'Participants: comma separated user-id\'s or -names', 'participants' => 'Participants: comma separated user-id\'s or -names',
'category' => 'Categories: id\'s or names, comma separated (new ones got created)', 'category' => 'Categories: id\'s or names, comma separated (new ones got created)',
'priority' => 'Priority: 1=Low, 2=Normal, 3=High', 'priority' => 'Priority: 1=Low, 2=Normal, 3=High',
@ -257,7 +257,7 @@
"<i>NFamily</i> AND (<i>NGiven</i> OR <i>Company</i>). This is necessary to link your imported calendar-entrys ". "<i>NFamily</i> AND (<i>NGiven</i> OR <i>Company</i>). This is necessary to link your imported calendar-entrys ".
"with the addressbook.<br>". "with the addressbook.<br>".
"<b>@cat_id(Cat1,...,CatN)</b> returns a (','-separated) list with the cat_id's. If a category isn't found, it ". "<b>@cat_id(Cat1,...,CatN)</b> returns a (','-separated) list with the cat_id's. If a category isn't found, it ".
"will be automaticaly added.<p>". "will be automaticaly added. This function is automaticaly called if the category is not numerical!<p>".
"I hope that helped to understand the features, if not <a href='mailto:RalfBecker@outdoor-training.de'>ask</a>."; "I hope that helped to understand the features, if not <a href='mailto:RalfBecker@outdoor-training.de'>ask</a>.";
$GLOBALS['phpgw']->template->set_var('help_on_trans',lang($help_on_trans)); // I don't think anyone will translate this $GLOBALS['phpgw']->template->set_var('help_on_trans',lang($help_on_trans)); // I don't think anyone will translate this
@ -360,10 +360,9 @@
{ {
//echo "<p>$csv: $info".($trans[$csv] ? ': '.$trans[$csv] : '')."</p>"; //echo "<p>$csv: $info".($trans[$csv] ? ': '.$trans[$csv] : '')."</p>";
$val = $fields[$csv_idx]; $val = $fields[$csv_idx];
if (isset($trans[$csv_idx])) if (isset($trans[$csv_idx]) && is_array($trans[$csv_idx]))
{ {
$trans_csv = $trans[$csv_idx]; foreach($trans[$csv_idx] as $pattern => $replace)
while (list($pattern,$replace) = each($trans_csv))
{ {
if (ereg((string) $pattern,$val)) if (ereg((string) $pattern,$val))
{ {
@ -464,21 +463,26 @@
$datearr['hour'],$datearr['minute'],$datearr['second']); $datearr['hour'],$datearr['minute'],$datearr['second']);
} }
// convert participants-names to user-id's // convert participants-names to user-id's
$parts = isset($values['participants']) ? split('[,;]',$values['participants']) : array($values['owner'].'=A'); $participants = 0;
foreach($parts as $part_status) foreach(split('[,;]',$values['participants']) as $part_status)
{ {
list($part,$status) = explode('=',$part_status); list($part,$status) = explode('=',$part_status);
$valid_status = array('U'=>'U','u'=>'U','A'=>'A','a'=>'A','R'=>'R','r'=>'R','T'=>'T','t'=>'T'); $valid_status = array('U'=>'U','u'=>'U','A'=>'A','a'=>'A','R'=>'R','r'=>'R','T'=>'T','t'=>'T');
$status = isset($valid_status[$status]) ? $valid_status[$status] : 'U'; $status = isset($valid_status[$status]) ? $valid_status[$status] : 'U';
if (!$GLOBALS['phpgw']->accounts->exists($part)) if ($GLOBALS['phpgw']->accounts->exists($part))
{ {
$part = $GLOBALS['phpgw']->accounts->name2id($part); $part = $GLOBALS['phpgw']->accounts->name2id($part);
} }
if ($part) if ($part && is_numeric($part))
{ {
$calendar->add_attribute('participants',$status,$part); $calendar->add_attribute('participants',$status,$part);
$participants++;
} }
} }
if (!$participants) // no valid participants so far --> add the importing user/owner
{
$calendar->add_attribute('participants','A',$values['owner']);
}
//echo "add_entry(<pre>".print_r($calendar->cal->event,True).")</pre>\n"; //echo "add_entry(<pre>".print_r($calendar->cal->event,True).")</pre>\n";
$calendar->add_entry( $calendar->cal->event ); $calendar->add_entry( $calendar->cal->event );
} }