diff --git a/apps/contacts/ajax/addcard.php b/apps/contacts/ajax/addcard.php index 7e47659d23..140d6a4809 100644 --- a/apps/contacts/ajax/addcard.php +++ b/apps/contacts/ajax/addcard.php @@ -22,6 +22,11 @@ // Init owncloud require_once('../../../lib/base.php'); +function bailOut($msg) { + OC_JSON::error(array('data' => array('message' => $msg))); + OC_Log::write('contacts','ajax/addcard.php: '.$msg, OC_Log::DEBUG); + exit(); +} // Check if we are a user OC_JSON::checkLoggedIn(); @@ -31,12 +36,22 @@ $l=new OC_L10N('contacts'); $aid = $_POST['id']; $addressbook = OC_Contacts_App::getAddressbook( $aid ); -$fn = $_POST['fn']; +$fn = trim($_POST['fn']); $values = $_POST['value']; $parameters = $_POST['parameters']; $vcard = new OC_VObject('VCARD'); $vcard->setUID(); + +$n = isset($values['N'][0])?trim($values['N'][0]).';':';'; +$n .= isset($values['N'][1])?trim($values['N'][1]).';':';'; +$n .= isset($values['N'][2])?trim($values['N'][2]).';;':';;'; + +if(!$fn || ($n == ';;;;')) { + bailOut('You have to enter both the extended name and the display name.'); +} + +$vcard->setString('N',$n); $vcard->setString('FN',$fn); // Data to add ... @@ -58,6 +73,10 @@ foreach( $add as $propname){ } else { $prop_parameters = array(); } + if(is_array($value)){ + ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form! + $value = OC_VObject::escapeSemicolons($value); + } $vcard->addProperty($propname, $value); //, $prop_parameters); $line = count($vcard->children) - 1; foreach ($prop_parameters as $key=>$element) { @@ -77,7 +96,7 @@ foreach( $add as $propname){ $id = OC_Contacts_VCard::add($aid,$vcard->serialize()); if(!$id) { OC_JSON::error(array('data' => array('message' => $l->t('There was an error adding the contact.')))); - OC_Log::write('contacts','ajax/addcard.php: Recieved non-positive ID on adding card: '.$name, OC_Log::ERROR); + OC_Log::write('contacts','ajax/addcard.php: Recieved non-positive ID on adding card: '.$id, OC_Log::ERROR); exit(); } diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php index f016820ce5..c90af217c8 100644 --- a/apps/contacts/ajax/addproperty.php +++ b/apps/contacts/ajax/addproperty.php @@ -54,6 +54,21 @@ if(!is_array($value)){ } $parameters = isset($_POST['parameters']) ? $_POST['parameters'] : array(); +// Prevent setting a duplicate entry +$current = $vcard->select($name); +foreach($current as $item) { + $tmpvalue = (is_array($value)?implode(';', $value):$value); + if($tmpvalue == $item->value) { + OC_JSON::error(array('data' => array('message' => $l->t('Trying to add duplicate property: ').$name.': '.$tmpvalue))); + OC_Log::write('contacts','ajax/addproperty.php: Trying to add duplicate property: '.$name.': '.$tmpvalue, OC_Log::DEBUG); + exit(); + } +} + +if(is_array($value)) { + ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form! +} + $property = $vcard->addProperty($name, $value); //, $parameters); $line = count($vcard->children) - 1; diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php index 89cf292f4f..d745d3271d 100644 --- a/apps/contacts/ajax/deleteproperty.php +++ b/apps/contacts/ajax/deleteproperty.php @@ -33,6 +33,11 @@ $checksum = $_GET['checksum']; $vcard = OC_Contacts_App::getContactVCard( $id ); $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); +if(is_null($line)){ + $l=new OC_L10N('contacts'); + OC_JSON::error(array('data' => array( 'message' => $l->t('Information about vCard is incorrect. Please reload the page.')))); + exit(); +} unset($vcard->children[$line]); diff --git a/apps/contacts/ajax/setproperty.php b/apps/contacts/ajax/setproperty.php index cdc6d34c52..cf3fe58224 100644 --- a/apps/contacts/ajax/setproperty.php +++ b/apps/contacts/ajax/setproperty.php @@ -36,8 +36,9 @@ $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); // Set the value $value = $_POST['value']; if(is_array($value)){ - $value = OC_VObject::escapeSemicolons($value); + ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form! } +OC_Log::write('contacts','ajax/setproperty.php: setting: '.$vcard->children[$line]->name.': '.$value, OC_Log::DEBUG); $vcard->children[$line]->setValue($value); // Add parameters @@ -87,6 +88,9 @@ $phone_types = OC_Contacts_App::getTypesOfProperty('TEL'); if ($vcard->children[$line]->name == 'FN'){ $tmpl = new OC_Template('contacts','part.property.FN'); } +elseif ($vcard->children[$line]->name == 'N'){ + $tmpl = new OC_Template('contacts','part.property.N'); +} else{ $tmpl = new OC_Template('contacts','part.property'); } diff --git a/apps/contacts/ajax/showsetproperty.php b/apps/contacts/ajax/showsetproperty.php index e23fa21c56..577230e456 100644 --- a/apps/contacts/ajax/showsetproperty.php +++ b/apps/contacts/ajax/showsetproperty.php @@ -33,6 +33,11 @@ $checksum = $_GET['checksum']; $vcard = OC_Contacts_App::getContactVCard( $id ); $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); +if(is_null($line)){ + $l=new OC_L10N('contacts'); + OC_JSON::error(array('data' => array( 'message' => $l->t('Information about vCard is incorrect. Please reload the page.')))); + exit(); +} $adr_types = OC_Contacts_App::getTypesOfProperty('ADR'); $phone_types = OC_Contacts_App::getTypesOfProperty('TEL'); diff --git a/apps/contacts/css/styles.css b/apps/contacts/css/styles.css index 4fcd8fc113..58e1bf6c93 100644 --- a/apps/contacts/css/styles.css +++ b/apps/contacts/css/styles.css @@ -2,6 +2,7 @@ #leftcontent a { height: 23px; display: block; margin: 0 0 0 0; padding: 0 0 0 25px; } #chooseaddressbook {margin-right: 170px; float: right;} #contacts_details_name { font-weight:bold;font-size:1.1em;margin-left:25%;} +#contacts_details_name_n { font-size:0.8em;margin-left:25%;color:#666;} #contacts_details_photo { margin:.5em 0em .5em 25%; } #contacts_deletecard {position:absolute;top:15px;right:25px;} @@ -12,41 +13,15 @@ #contacts_details_list li p.contacts_property_data, #contacts_details_list li ul.contacts_property_data { width:72%;float:left; clear: right; } #contacts_setproperty_button { margin-left:25%; } -dl.form -{ - width: 100%; - float: left; - clear: right; - margin: 1em; - padding: 0; -} +#contacts_addcardform legend,label { font-weight: bold; width: 10em; overflow: ellipsis; } +#contacts_addcardform legend { padding-left: 3em; font-size:1.1em; } +#contacts_addcardform input[type="text"] { width: 25em; } +#contacts_addcardform input[type="email"] { width: 15em; } +#contacts_addcardform input[type="tel"] { width: 15em; } -.form dt -{ - display: table-cell; - clear: left; - float: left; - min-width: 10em; - margin: 0; - padding-top: 0.5em; - padding-right: 1em; - font-weight: bold; - text-align:right; - vertical-align: text-bottom; - bottom: 0px; -} - -.form dd -{ - display: table-cell; - clear: right; - float: left; - min-width: 20em; - margin: 0; - padding: 0; - white-space: nowrap; - top: 0px; -} +dl.form { width: 100%; float: left; clear: right; margin: 1em; padding: 0; } +.form dt { display: table-cell; clear: left; float: left; min-width: 10em; margin: 0; padding-top: 0.5em; padding-right: 1em;font-weight: bold; text-align:right; vertical-align: text-bottom; bottom: 0px; } +.form dd { display: table-cell; clear: right; float: left; min-width: 20em; margin: 0; padding: 0; white-space: nowrap; top: 0px; } .form input { position: relative; width: 20em; } .contacts_property_data ul, ol.contacts_property_data { list-style:none; } @@ -60,18 +35,3 @@ dl.form .chzn-container.chzn-container-active .chzn-choices { border-bottom-left-radius: 0;border-bottom-right-radius: 0; } .chzn-container .chzn-drop { border-bottom-left-radius: 0.5em;border-bottom-right-radius: 0.5em; } -/* Form setup ----------------------------------------------------------------*/ -/* .forme {} */ -/* .forme ul, .forme ol { list-style:none; } */ -/* .forme .inputs, .forme .buttons { overflow: hidden; } */ - -/* Labels --------------------------------------------------------------------*/ -/* .forme .input .label { width:25%; float:left; display:block; } */ - -/* Inputs --------------------------------------------------------------------*/ -/* .forme .stringish input { width:72%; } */ -/* .forme .text textarea { width:72%; } */ - -/* Buttons -------------------------------------------------------------------*/ -/* .forme .buttons { padding-left:25%; } */ -/* .forme .button { float:left; padding-left:0.5em; } */ diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php index bc1e4974b3..580cc72d5e 100644 --- a/apps/contacts/lib/app.php +++ b/apps/contacts/lib/app.php @@ -85,10 +85,6 @@ class OC_Contacts_App{ break; } } - if(is_null($line)){ - OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('Information about vCard is incorrect. Please reload the page.')))); - exit(); - } return $line; } diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php index ceac2dcfad..aefa2c7411 100644 --- a/apps/contacts/lib/vcard.php +++ b/apps/contacts/lib/vcard.php @@ -320,6 +320,8 @@ class OC_Contacts_VCard{ * ['value'] htmlspecialchars escaped value of property * ['parameters'] associative array name=>value * ['checksum'] checksum of whole property + * NOTE: $value is not escaped anymore. It shouldn't make any difference + * but we should look out for any problems. */ public static function structureProperty($property){ $value = $property->value; diff --git a/apps/contacts/photo.php b/apps/contacts/photo.php index 478ef829ca..756aae63c4 100644 --- a/apps/contacts/photo.php +++ b/apps/contacts/photo.php @@ -63,6 +63,9 @@ if( is_null($content)){ } } if($image->loadFromBase64($child->value)) { + if($image->width() > 200 || $image->height() > 200) { + $image->resize(200); + } header('Content-Type: '.$mime); $image(); exit(); diff --git a/apps/contacts/templates/part.addcardform.php b/apps/contacts/templates/part.addcardform.php index 11457ff269..17207d2ebc 100644 --- a/apps/contacts/templates/part.addcardform.php +++ b/apps/contacts/templates/part.addcardform.php @@ -1,11 +1,14 @@ -
+ +
- +

+
- + + +
+ +
+
+ + +
+ + + +
+
+
+
+
+
+ + +
+ +
+
+
@@ -34,16 +61,16 @@
- +
- +
- + @@ -54,7 +81,7 @@ t('Address'); ?>
- +
- +
- +
-
+
- +
- + + +
- +
- + + +
- +
- +
-
+
- +
diff --git a/apps/contacts/templates/part.details.php b/apps/contacts/templates/part.details.php index 679ae5ede2..5badd81615 100644 --- a/apps/contacts/templates/part.details.php +++ b/apps/contacts/templates/part.details.php @@ -1,5 +1,6 @@ inc('part.property.FN', array('property' => $_['details']['FN'][0])); ?> + inc('part.property.N', array('property' => $_['details']['N'][0])); ?> diff --git a/apps/contacts/templates/part.messagebox.php b/apps/contacts/templates/part.messagebox.php index 3681bb6e3f..5db10e7e6c 100644 --- a/apps/contacts/templates/part.messagebox.php +++ b/apps/contacts/templates/part.messagebox.php @@ -1,7 +1,3 @@
- - - - -
+
diff --git a/apps/contacts/templates/part.property.N.php b/apps/contacts/templates/part.property.N.php new file mode 100644 index 0000000000..73d599ad7b --- /dev/null +++ b/apps/contacts/templates/part.property.N.php @@ -0,0 +1,4 @@ +

+ () + +

diff --git a/apps/contacts/templates/part.setpropertyform.php b/apps/contacts/templates/part.setpropertyform.php index 3e0b8d49b5..49fa966214 100644 --- a/apps/contacts/templates/part.setpropertyform.php +++ b/apps/contacts/templates/part.setpropertyform.php @@ -1,46 +1,79 @@ - + +

+

+
+
+
+
+
+
+ + +
+
+

+

-
    -
  1. +
    +
    +
    +
    -
  2. -
  3. +
+
+
+
- -
  • +
  • + +
    - - -
  • +
  • +
    + + +
    +
    - - -
  • - - -
  • -
  • +
  • +
    + - - -
  • + +
  • +
    + +
    +
    + +
    + +
    - - - +
    +
    + +
    +