All the basic field for add contact added

This commit is contained in:
Bart Visscher 2011-10-04 21:13:44 +02:00
parent 4bcb6f5346
commit fada3517b0
4 changed files with 59 additions and 11 deletions

View file

@ -44,9 +44,10 @@ $vcard->add(new Sabre_VObject_Property('UID',OC_Contacts_VCard::createUID()));
$id = OC_Contacts_VCard::add($aid,$vcard->serialize());
$details = OC_Contacts_VCard::structureContact($vcard);
$name = $details['FN'][0]['value'];
$tmpl = new OC_Template('contacts','part.details');
$tmpl->assign('details',$details);
$tmpl->assign('id',$id);
$page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page )));
OC_JSON::success(array('data' => array( 'id' => $id, 'name' => $name, 'page' => $page )));

View file

@ -53,16 +53,7 @@ $name = $_POST['name'];
$value = $_POST['value'];
$parameters = isset($_POST['parameteres'])?$_POST['parameters']:array();
if(is_array($value)){
$value = OC_Contacts_VCard::escapeSemicolons($value);
}
$property = new Sabre_VObject_Property( $name, $value );
$parameternames = array_keys($parameters);
foreach($parameternames as $i){
$property->parameters[] = new Sabre_VObject_Parameter($i,$parameters[$i]);
}
$vcard->add($property);
OC_Contacts_VCard::addVCardProperty($vcard, $name, $value, $parameters);
$line = count($vcard->children) - 1;
$checksum = md5($property->serialize());

View file

@ -272,6 +272,26 @@ class OC_Contacts_VCard{
return $array;
}
/**
* @brief Add property to vcard object
* @param object $vcard
* @param object $name of property
* @param object $value of property
* @param object $paramerters of property
*/
public static function addVCardProperty($vcard, $name, $value, $parameters=array()){
if(is_array($value)){
$value = OC_Contacts_VCard::escapeSemicolons($value);
}
$property = new Sabre_VObject_Property( $name, $value );
$parameternames = array_keys($parameters);
foreach($parameternames as $i){
$property->parameters[] = new Sabre_VObject_Parameter($i,$parameters[$i]);
}
$vcard->add($property);
}
/**
* @brief Data structure of vCard
* @param object $property

View file

@ -11,5 +11,41 @@
<?php endif; ?>
<label for="fn"><?php echo $l->t('Name'); ?></label>
<input type="text" name="fn" value=""><br>
<label for="ADR"><?php echo $l->t('Address'); ?></label>
<div id="contacts_addresspart">
<select id="ADR" name="parameters[ADR][TYPE]" size="1">
<option value="adr_work"><?php echo $l->t('Work'); ?></option>
<option value="adr_home" selected="selected"><?php echo $l->t('Home'); ?></option>
</select>
<p><label><?php echo $l->t('PO Box'); ?></label> <input type="text" name="value[ADR][0]" value=""></p>
<p><label><?php echo $l->t('Extended'); ?></label> <input type="text" name="value[ADR][1]" value=""></p>
<p><label><?php echo $l->t('Street'); ?></label> <input type="text" name="value[ADR][2]" value=""></p>
<p><label><?php echo $l->t('City'); ?></label> <input type="text" name="value[ADR][3]" value=""></p>
<p><label><?php echo $l->t('Region'); ?></label> <input type="text" name="value[ADR][4]" value=""></p>
<p><label><?php echo $l->t('Zipcode'); ?></label> <input type="text" name="value[ADR][5]" value=""></p>
<p><label><?php echo $l->t('Country'); ?></label> <input type="text" name="value[ADR][6]" value=""></p>
</div>
<label for="TEL"><?php echo $l->t('Telephone'); ?></label>
<div id="contacts_phonepart">
<select id="TEL" name="parameters[TEL][TYPE]" size="1">
<option value="home"><?php echo $l->t('Home'); ?></option>
<option value="cell" selected="selected"><?php echo $l->t('Mobile'); ?></option>
<option value="work"><?php echo $l->t('Work'); ?></option>
<option value="text"><?php echo $l->t('Text'); ?></option>
<option value="voice"><?php echo $l->t('Voice'); ?></option>
<option value="fax"><?php echo $l->t('Fax'); ?></option>
<option value="video"><?php echo $l->t('Video'); ?></option>
<option value="pager"><?php echo $l->t('Pager'); ?></option>
</select>
<input type="text" name="value[TEL]" value="">
</div>
<label for="EMAIL"><?php echo $l->t('Email'); ?></label>
<div id="contacts_email">
<input id="EMAIL" type="text" name="value[EMAIL]" value="">
</div>
<label for="ORG"><?php echo $l->t('Organization'); ?></label>
<div id="contacts_organisation">
<input id="ORG" type="text" name="value[ORG]" value="">
</div>
<input type="submit" name="submit" value="<?php echo $l->t('Create Contact'); ?>">
</form>