Horde_Icalendar_Vevent::updateFromvEvent PHP Метод

updateFromvEvent() публичный Метод

Update this event with details from another event.
public updateFromvEvent ( Horde_Icalendar_Vevent $vevent )
$vevent Horde_Icalendar_Vevent The vEvent with latest details.
    public function updateFromvEvent($vevent)
    {
        $newAttributes = $vevent->getAllAttributes();
        foreach ($newAttributes as $newAttribute) {
            try {
                $this->getAttribute($newAttribute['name']);
            } catch (Horde_Icalendar_Exception $e) {
                // Already exists so just add it.
                $this->setAttribute($newAttribute['name'], $newAttribute['value'], $newAttribute['params']);
                continue;
            }
            // Already exists so locate and modify.
            $found = false;
            // Try matching the attribte name and value incase
            // only the params changed (eg attendee updating
            // status).
            foreach ($this->_attributes as $id => $attr) {
                if ($attr['name'] == $newAttribute['name'] && $attr['value'] == $newAttribute['value']) {
                    // merge the params
                    foreach ($newAttribute['params'] as $param_id => $param_name) {
                        $this->_attributes[$id]['params'][$param_id] = $param_name;
                    }
                    $found = true;
                    break;
                }
            }
            if (!$found) {
                // Else match the first attribute with the same
                // name (eg changing start time).
                foreach ($this->_attributes as $id => $attr) {
                    if ($attr['name'] == $newAttribute['name']) {
                        $this->_attributes[$id]['value'] = $newAttribute['value'];
                        // Merge the params.
                        foreach ($newAttribute['params'] as $param_id => $param_name) {
                            $this->_attributes[$id]['params'][$param_id] = $param_name;
                        }
                        break;
                    }
                }
            }
        }
    }