process() 공개 메소드

Perform the import.
public process ( ) : array
리턴 array A hash of UID => id.
예제 #1
0
파일: data.php 프로젝트: horde/horde
        }
        try {
            $event->save();
        } catch (Exception $e) {
            $notification->push($e, 'horde.error');
            $error = true;
            break;
        }
        if ($max_events !== true) {
            $num_events++;
        }
    }
    if (!empty($ical)) {
        $ical_importer = new Kronolith_Icalendar_Handler_Base($ical, $kronolith_driver);
        try {
            $ical_importer->process();
        } catch (Kronolith_Exception $e) {
            $msg = _("Can't create a new event.") . ' ' . sprintf(_("This is what the server said: %s"), $e->getMessage());
            $notification->push($msg, 'horde.error');
            $error = true;
        }
    }
    if (!$error) {
        $notification->push(sprintf(_("%s file successfully imported"), $file_types[$storage->get('format')]), 'horde.success');
    }
    if (Horde_Util::getFormData('import_ajax')) {
        $page_output->addInlineScript('(function(window){window.KronolithCore.loadCalendar(\'' . $type . '\', \'' . $calendar . '\');})(window.parent)');
    }
    $next_step = $data->cleanup();
}
if (Horde_Util::getFormData('import_ajax')) {
예제 #2
0
파일: Api.php 프로젝트: horde/horde
 /**
  * Imports an event represented in the specified content type.
  *
  * @param string $content      The content of the event.
  * @param string $contentType  What format is the data in? Currently supports:
  *                             <pre>
  *                             text/calendar
  *                             text/x-vcalendar
  *                             activesync
  *                             </pre>
  * @param string $calendar     What calendar should the event be added to?
  * @param boolean $hash        If true, return a hash for EAS additions.
  *                             @since  4.3.0 @todo Remove for 5.0 and make
  *                             this the normal return.
  *
  * @return array  The event's UID.
  * @throws Kronolith_Exception
  */
 public function import($content, $contentType, $calendar = null, $hash = false)
 {
     if (!isset($calendar)) {
         $calendar = Kronolith::getDefaultCalendar(Horde_Perms::EDIT);
     } elseif (!Kronolith::hasPermission($calendar, Horde_Perms::EDIT)) {
         throw new Horde_Exception_PermissionDenied();
     }
     $kronolith_driver = Kronolith::getDriver(null, $calendar);
     switch ($contentType) {
         case 'text/calendar':
         case 'text/x-vcalendar':
             $iCal = new Horde_Icalendar();
             if (!$content instanceof Horde_Icalendar_Vevent) {
                 if (!$iCal->parsevCalendar($content)) {
                     throw new Kronolith_Exception(_("There was an error importing the iCalendar data."));
                 }
             } else {
                 $iCal->addComponent($content);
             }
             $ical_importer = new Kronolith_Icalendar_Handler_Base($iCal, $kronolith_driver);
             $result = array_flip($ical_importer->process());
             return current($result);
         case 'activesync':
             $event = $kronolith_driver->getEvent();
             $event->fromASAppointment($content);
             $event->save();
             // Handle attachment data after we commit changes since we
             // are required to have a saved event to attach files. Also,
             // we can only handle files if we are returning a hash since EAS
             // needs the information returned to attach filereferences to
             // the attachments.
             if (!$hash) {
                 return $event->uid;
             }
             $atc_hash = $event->addEASFiles($content);
             return array('uid' => $event->uid, 'atchash' => $atc_hash);
     }
     throw new Kronolith_Exception(sprintf(_("Unsupported Content-Type: %s"), $contentType));
 }
예제 #3
0
파일: Api.php 프로젝트: raz0rsdge/horde
 /**
  * Imports an event represented in the specified content type.
  *
  * @param string $content      The content of the event.
  * @param string $contentType  What format is the data in? Currently supports:
  *                             <pre>
  *                             text/calendar
  *                             text/x-vcalendar
  *                             activesync
  *                             </pre>
  * @param string $calendar     What calendar should the event be added to?
  *
  * @return array  The event's UID.
  * @throws Kronolith_Exception
  */
 public function import($content, $contentType, $calendar = null)
 {
     if (!isset($calendar)) {
         $calendar = Kronolith::getDefaultCalendar(Horde_Perms::EDIT);
     } elseif (!Kronolith::hasPermission($calendar, Horde_Perms::EDIT)) {
         throw new Horde_Exception_PermissionDenied();
     }
     $kronolith_driver = Kronolith::getDriver(null, $calendar);
     switch ($contentType) {
         case 'text/calendar':
         case 'text/x-vcalendar':
             $iCal = new Horde_Icalendar();
             if (!$content instanceof Horde_Icalendar_Vevent) {
                 if (!$iCal->parsevCalendar($content)) {
                     throw new Kronolith_Exception(_("There was an error importing the iCalendar data."));
                 }
             } else {
                 $iCal->addComponent($content);
             }
             $ical_importer = new Kronolith_Icalendar_Handler_Base($iCal, $kronolith_driver);
             $result = array_flip($ical_importer->process());
             return current($result);
         case 'activesync':
             $event = $kronolith_driver->getEvent();
             $event->fromASAppointment($content);
             $event->save();
             return $event->uid;
     }
     throw new Kronolith_Exception(sprintf(_("Unsupported Content-Type: %s"), $contentType));
 }