diff --git a/calendar/calendar_import_form.php b/calendar/calendar_import_form.php
new file mode 100644
index 0000000..1e75f89
--- /dev/null
+++ b/calendar/calendar_import_form.php
@@ -0,0 +1,19 @@
+<?php
+require_once '../config.php';
+require_once($CFG->libdir.'/formslib.php');
+
+class calendar_import_form extends moodleform {
+    
+    /**
+     * Defines the form elements
+     */
+    function definition() {
+        $mform    =& $this->_form;        
+        $mform->addElement('file', 'importfile', get_string('importcalendar', 'calendar'));
+        $mform->addElement('hidden', 'courseid');
+
+        $this->add_action_buttons(false);
+    }
+}
+
+?>
diff --git a/calendar/import.php b/calendar/import.php
new file mode 100644
index 0000000..ad39d5e
--- /dev/null
+++ b/calendar/import.php
@@ -0,0 +1,86 @@
+<?php
+
+require_once('../config.php');
+require_once($CFG->dirroot.'/calendar/lib.php');
+require_once($CFG->libdir.'/tablelib.php');
+require_once($CFG->dirroot.'/calendar/calendar_import_form.php');
+
+$courseid = required_param('courseid', PARAM_INT);
+
+$course = get_record('course', 'id', $courseid);
+
+if ($courseid && $courseid != SITEID) {
+    require_login($courseid);
+} else if ($CFG->forcelogin) {
+    require_login();
+}
+
+
+$now = usergetdate(time());
+$navlinks = array();
+$navlinks[] = array('name' => get_string('calendar', 'calendar'),
+                    'link' =>calendar_get_link_href(CALENDAR_URL.'view.php?view=upcoming&amp;course='.$courseid.'&amp;', $now['mday'], $now['mon'], $now['year']),
+                    'type' => 'misc');
+$navlinks[] = array('name' => get_string('importcalendar', 'calendar'), 'link' =>'', 'type' => 'misc');
+
+$navigation = build_navigation($navlinks);
+
+print_header_simple(get_string('importcalendar', 'calendar'), '', $navigation);
+
+echo '<h1>'.get_string('importcalendar', 'calendar').'</h1>';
+
+$mform = new calendar_import_form();
+$data = new stdClass;
+$data->courseid = $courseid;
+$mform->set_data($data);
+
+if ($formdata = $mform->get_data()) {
+    $ical_events = ical_reader($_FILES['importfile']['tmp_name']);
+    $table = new flexible_table('ical_import');
+    $columns = array('summary', 'start', 'duration', 'user');
+    $headers = array('Summary', 'Start', 'Duration', 'User');
+    $table->define_columns($columns);
+    $table->define_headers($headers);
+    $table->setup();
+    $count = 0;
+    
+    foreach($ical_events as $event) {
+        if($count < 20) {
+        $mevent = new stdClass;
+        $mevent->name = $event->SUMMARY;
+        $mevent->description = $event->DESCRIPTION;
+        $mevent->courseid = $courseid;
+        $mevent->timestart = strtotime($event->DTSTART);
+        $mevent->duration = strtotime($event->DTEND) - $mevent->timestart;
+        if($user = get_record('user', 'email', $event->ORGANIZER['email'])) {
+        	$mevent->user = $user;
+        } else {
+        	$mevent->user = $USER;
+        }
+            
+            
+        $mevent->timemodified = time();
+        
+        
+        	$row = array();
+            $row[] = $mevent->name;
+            $row[] = date('d/m/Y H:i', $mevent->timestart);
+            $row[] = date('H:i', $mevent->duration);
+            $row[] = fullname($mevent->user);
+            $table->add_data($row);
+        }
+        $count++;        
+        
+    }
+    echo '<h2>Import Preview</h2>';
+    $table->print_html();
+    echo ($count-20).' more...';
+}
+
+$mform->display();
+
+print_footer();
+
+
+?>
+
diff --git a/calendar/lib.php b/calendar/lib.php
index 3596ed5..33e13c6 100644
--- a/calendar/lib.php
+++ b/calendar/lib.php
@@ -1619,4 +1619,50 @@ function calendar_user_can_add_event() {
     calendar_get_allowed_types($allowed);
     return (bool)($allowed->user || $allowed->groups || $allowed->courses || $allowed->site);
 }
+
+/**
+ * Parses an iCal (.ics) file into an array.
+ * 
+ * Based on ical-parser-class by Nihaopaul - {@link http://nihaopaul.com/}
+ * 
+ * @param string $file The filename of the ical file
+ * @return array An array of events from the file
+ */
+function ical_reader($file) {
+        $events = array();
+        if($fp = fopen($file, 'r')){
+            while (!feof($fp)) {
+            	$line = fgets($fp);
+                if(preg_match('/([\w-]+)[:;]([\w \\\.-@]*)/', $line, $data)) {
+                    
+                    if($data[1] == 'BEGIN' && $data[2] == 'VEVENT') {
+                        
+                        if(isset($event)) {                            
+                            $events[] = $event;
+                        }                
+                        $event = new stdClass;
+                                            
+                    } else if(isset($event)) {
+                        
+                        if($data[1] == 'ORGANIZER') {
+                        	if(preg_match('/CN=([\w ]+).*:([\w\.%+-]+@[\w.-]+\.[A-Za-z]{2,4})/', $data[2], $user)) {
+
+                        		$event->$data[1] = array('name' => $user[1], 'email' => $user[2]);
+                        	}
+                        } else {
+                            if(!empty($data[2])) {
+                                $event->$data[1] = $data[2];
+                            }   	
+                        }
+                                       
+                        
+                    }	
+                }
+                                
+            }	
+        }        
+        
+        return $events;
+    }
+    
 ?>
diff --git a/calendar/view.php b/calendar/view.php
index 92abf88..6189933 100644
--- a/calendar/view.php
+++ b/calendar/view.php
@@ -43,7 +43,7 @@
     require_once('../config.php');
     require_once($CFG->dirroot.'/course/lib.php');
     require_once($CFG->dirroot.'/calendar/lib.php');
-
+    
     $courseid = optional_param('course', 0, PARAM_INT);
     $view = optional_param('view', 'upcoming', PARAM_ALPHA);
     $day  = optional_param('cal_d', 0, PARAM_INT);
@@ -179,7 +179,8 @@
                  .'</a>';
         }
     }
-
+    print_single_button('import.php', array('courseid'=>$courseid), get_string('importcalendar', 'calendar'));
+    
     echo '</div>';
     echo '</div>';
     echo '</td>';
diff --git a/lang/en_utf8/calendar.php b/lang/en_utf8/calendar.php
index 43928ff..893b8e7 100644
--- a/lang/en_utf8/calendar.php
+++ b/lang/en_utf8/calendar.php
@@ -68,6 +68,7 @@ $string['groupevent'] = 'Group event';
 $string['groupevents'] = 'Group events';
 $string['hidden'] = 'hidden';
 $string['ical'] = 'iCal';
+$string['importcalendar'] = 'Import calendar';
 $string['iwanttoexport'] = 'Export';
 $string['manyevents'] = '$a events';
 $string['mon'] = 'Mon';
