]> source.dussan.org Git - nextcloud-server.git/commitdiff
All the basic field for add contact added
authorBart Visscher <bartv@thisnet.nl>
Tue, 4 Oct 2011 19:13:44 +0000 (21:13 +0200)
committerBart Visscher <bartv@thisnet.nl>
Tue, 4 Oct 2011 19:16:57 +0000 (21:16 +0200)
apps/contacts/ajax/addcard.php
apps/contacts/ajax/addproperty.php
apps/contacts/lib/vcard.php
apps/contacts/templates/part.addcardform.php

index ee95513732de9277f98243221d6c544048eac73b..70e0f0a89d0940c5111c7d6b6589691b1ee1baf4 100644 (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 )));
index 0b218c6298f64489cd3e1fb4ad956eab50ecb65f..68c4f65fa5c74e5f5b434912e45f77539a036c84 100644 (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());
index 1c9a8049f7310df62cc371ef2a00d343ca1fac74..78327ab15e1ae089ec3155522e6475143b08bf1f 100644 (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
index e87c64507dce6f913e84be3af7b535d70a68ab24..c7d668fae58030584461f35c3c31c518279e9977 100644 (file)
        <?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>