/** * Replaces the x-prop_name value. Replaces the prop_name value IF the old value is the same as the old value of x-prop_name (meaning: the user has not manually changed it) * * @param Sabre\VObject\Component $component * @param string $prop_name * @param string $prop_value * @param array $parameters * @return void */ public static function card_set_automatic_value(&$component, $prop_name, $prop_value, $parameters = array()) { $automatic = $component->select("X-" . $prop_name); $curr = $component->select($prop_name); if (count($automatic) == 0) { $prop = new Sabre\VObject\Property('X-' . $prop_name, $prop_value); foreach ($parameters as $key => $val) { $prop->add($key, $val); } $component->children[] = $prop; if (count($curr) == 0) { $prop = new Sabre\VObject\Property($prop_name, $prop_value); foreach ($parameters as $key => $val) { $prop->add($key, $val); } $component->children[] = $prop; } } else { foreach ($automatic as $auto_prop) { /** @var Sabre\VObject\Property $auto_prop */ /** @var Sabre\VObject\Property $actual_prop */ foreach ($curr as $actual_prop) { if ($auto_prop->value == $actual_prop->value) { $actual_prop->setValue($prop_value); } } $auto_prop->setValue($prop_value); } } }