Hi,
First, I'll introduce myself. My name is Bas Wijnen, I am a high school
physics teacher in the Netherlands. I am also an experienced programmer
(although, as with many, I'm not too good at finishing projects), mostly
in C, C++ and python, but I can read and hack PHP (and MySQL) without a
problem. I'm a member of Debian and maintain a few packages for it (as
wij...@debian.org).
At my school, we don't currently have an electronic learning system. We
want one, and are looking at what those systems are used for by others,
so we can implement something in a way that is useful. I insisted that
we should try out Chamilo, and for that reason we are now running a
pilot with it (1.8.7). This pilot doesn't cover the whole school, but
only the physics department.
So far, I'm quite happy with it. There are some things though, mainly
for the platform manager, which need some improvement IMO. I've started
writing patches for those.[1]
So with this introduction comes the first patch as well. The agenda can
import ical files, but it will only look at the first appointment in it.
It is impossible to import a long list at once. I needed that, and since
I can't stand doing repetitive work, I wrote a patch to support it. I've
attached the patch. Since I changed some indentation (are there
guidelines within the project?), a bit of "unchanged" code is included
in the patch.
Is this list the preferred place to send patches, or is there a tracker
somewhere?
Thanks,
Bas
[1] I may sometimes forget to include license information. Whenever I
send something to the project, I license my code under the GNU GPL
version 3 or later.
--- agenda.inc.php.orig 2011-05-21 09:18:59.950546621 +0200
+++ agenda.inc.php 2011-05-21 20:04:53.640558488 +0200
@@ -4340,7 +4340,7 @@
$done = false;
if ((!is_null($to))or (!empty($_SESSION['toolgroup']))) // !is_null($to): when no user is selected we send it to everyone
{
- $send_to=separate_users_groups($to);
+ $send_to=separate_users_groups(explode('|', $to));
// storing the selected groups
if (is_array($send_to['groups']))
{
@@ -4613,65 +4613,73 @@
$ical->setConfig('filename', basename($filepath) );
$return = $ical->parse();
- //we need to recover: summary, description, dtstart, dtend, organizer, attendee, location (=course name),
-
- $ve = $ical->getComponent(VEVENT);
-
-
- $ttitle = $ve->getProperty('summary');
- $title = api_convert_encoding($ttitle,$charset,'UTF-8');
-
- $tdesc = $ve->getProperty('description');
- $desc = api_convert_encoding($tdesc,$charset,'UTF-8');
-
- $start_date = $ve->getProperty('dtstart');
- $start_date_string = $start_date['year'].'-'.$start_date['month'].'-'.$start_date['day'].' '.$start_date['hour'].':'.$start_date['min'].':'.$start_date['sec'];
-
-
- $ts = $ve->getProperty('dtend');
- if ($ts) {
- $end_date_string = $ts['year'].'-'.$ts['month'].'-'.$ts['day'].' '.$ts['hour'].':'.$ts['min'].':'.$ts['sec'];
- } else {
- //Check duration if dtend does not exist
- $duration = $ve->getProperty('duration');
- if ($duration) {
- $duration = $ve->getProperty('duration');
- $duration_string = $duration['year'].'-'.$duration['month'].'-'.$duration['day'].' '.$duration['hour'].':'.$duration['min'].':'.$duration['sec'];
- $start_date_tms = mktime(intval($start_date['hour']), intval($start_date['min']), intval($start_date['sec']), intval($start_date['month']), intval($start_date['day']), intval($start_date['year']));
- //$start_date_tms = mktime(($start_date['hour']), ($start_date['min']), ($start_date['sec']), ($start_date['month']), ($start_date['day']), ($start_date['year']));
- //echo date('d-m-Y - h:i:s', $start_date_tms);
-
- $end_date_string = mktime(intval($start_date['hour']) +$duration['hour'], intval($start_date['min']) + $duration['min'], intval($start_date['sec']) + $duration['sec'], intval($start_date['month']) + $duration['month'], intval($start_date['day'])+$duration['day'], intval($start_date['year']) + $duration['year']);
- $end_date_string = date('Y-m-d H:i:s', $end_date_string);
- //echo date('d-m-Y - h:i:s', $end_date_string);
+ $eventcount = 0;
+ while (true) {
+ //we need to recover: summary, description, dtstart, dtend, organizer, attendee, location (=course name),
+
+ $ve = $ical->getComponent(VEVENT, $eventcount);
+ if (!$ve)
+ break;
+
+
+ $ttitle = $ve->getProperty('summary');
+ $title = api_convert_encoding($ttitle,$charset,'UTF-8');
+
+ $tdesc = $ve->getProperty('description');
+ $desc = api_convert_encoding($tdesc,$charset,'UTF-8');
+
+ $start_date = $ve->getProperty('dtstart');
+ $start_date_string = $start_date['year'].'-'.$start_date['month'].'-'.$start_date['day'].' '.$start_date['hour'].':'.$start_date['min'].':'.$start_date['sec'];
+
+
+ $ts = $ve->getProperty('dtend');
+ if ($ts) {
+ $end_date_string = $ts['year'].'-'.$ts['month'].'-'.$ts['day'].' '.$ts['hour'].':'.$ts['min'].':'.$ts['sec'];
+ } else {
+ //Check duration if dtend does not exist
+ $duration = $ve->getProperty('duration');
+ if ($duration) {
+ $duration = $ve->getProperty('duration');
+ $duration_string = $duration['year'].'-'.$duration['month'].'-'.$duration['day'].' '.$duration['hour'].':'.$duration['min'].':'.$duration['sec'];
+ $start_date_tms = mktime(intval($start_date['hour']), intval($start_date['min']), intval($start_date['sec']), intval($start_date['month']), intval($start_date['day']), intval($start_date['year']));
+ //$start_date_tms = mktime(($start_date['hour']), ($start_date['min']), ($start_date['sec']), ($start_date['month']), ($start_date['day']), ($start_date['year']));
+ //echo date('d-m-Y - h:i:s', $start_date_tms);
+
+ $end_date_string = mktime(intval($start_date['hour']) +$duration['hour'], intval($start_date['min']) + $duration['min'], intval($start_date['sec']) + $duration['sec'], intval($start_date['month']) + $duration['month'], intval($start_date['day'])+$duration['day'], intval($start_date['year']) + $duration['year']);
+ $end_date_string = date('Y-m-d H:i:s', $end_date_string);
+ //echo date('d-m-Y - h:i:s', $end_date_string);
+ } else {
+ $end_date_string = $start_date_string;
+ }
}
- }
- //echo $start_date.' - '.$end_date;
- $organizer = $ve->getProperty('organizer');
- $attendee = $ve->getProperty('attendee');
- $course_name = $ve->getProperty('location');
- //insert the event in our database
- //var_dump($title,$desc,$start_date,$end_date);
- $id = agenda_add_item($course_info,$title,$desc,$start_date_string,$end_date_string,$_POST['selectedform']);
-
- $repeat = $ve->getProperty('rrule');
- if(is_array($repeat) && !empty($repeat['FREQ'])) {
- $trans = array('DAILY'=>'daily','WEEKLY'=>'weekly','MONTHLY'=>'monthlyByDate','YEARLY'=>'yearly');
- $freq = $trans[$repeat['FREQ']];
- $interval = $repeat['INTERVAL'];
- if(isset($repeat['UNTIL']) && is_array($repeat['UNTIL']))
- {
- $until = mktime(23,59,59,$repeat['UNTIL']['month'],$repeat['UNTIL']['day'],$repeat['UNTIL']['year']);
- $res = agenda_add_repeat_item($course_info,$id,$freq,$until,$_POST['selectedform']);
- }
- //TODO: deal with count
- if(!empty($repeat['COUNT']))
- {
- $count = $repeat['COUNT'];
- $res = agenda_add_repeat_item($course_info,$id,$freq,$count,$_POST['selectedform']);
- }
+ //echo $start_date.' - '.$end_date;
+ $organizer = $ve->getProperty('organizer');
+ $attendee = $ve->getProperty('attendee');
+ $course_name = $ve->getProperty('location');
+ //insert the event in our database
+ //var_dump($title,$desc,$start_date,$end_date);
+ $id = agenda_add_item($course_info,$title,$desc,$start_date_string,$end_date_string,$attendee);
+
+ $repeat = $ve->getProperty('rrule');
+ if(is_array($repeat) && !empty($repeat['FREQ'])) {
+ $trans = array('DAILY'=>'daily','WEEKLY'=>'weekly','MONTHLY'=>'monthlyByDate','YEARLY'=>'yearly');
+ $freq = $trans[$repeat['FREQ']];
+ $interval = $repeat['INTERVAL'];
+ if(isset($repeat['UNTIL']) && is_array($repeat['UNTIL']))
+ {
+ $until = mktime(23,59,59,$repeat['UNTIL']['month'],$repeat['UNTIL']['day'],$repeat['UNTIL']['year']);
+ $res = agenda_add_repeat_item($course_info,$id,$freq,$until,$attendee);
+ }
+ //TODO: deal with count
+ if(!empty($repeat['COUNT']))
+ {
+ $count = $repeat['COUNT'];
+ $res = agenda_add_repeat_item($course_info,$id,$freq,$count,$attendee);
+ }
+ }
+ $eventcount ++;
}
return true;
}
_______________________________________________
Dev mailing list
Dev@lists.chamilo.org
http://lists.chamilo.org/listinfo/dev