summaryrefslogtreecommitdiff
path: root/program/include/rcube_csv2vcard.php
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-11-16 14:45:02 +0100
committerAleksander Machniak <alec@alec.pl>2012-11-16 14:45:02 +0100
commitc66b605435cae82f8d61329aed79f514d771ab7a (patch)
treef6076784bdeed38fc72f3915b2ebf68ac19dd9f5 /program/include/rcube_csv2vcard.php
parent3833790db4dee8607b31c84f26eb0e95bae4c906 (diff)
Add more data validation
Diffstat (limited to 'program/include/rcube_csv2vcard.php')
-rw-r--r--program/include/rcube_csv2vcard.php28
1 files changed, 20 insertions, 8 deletions
diff --git a/program/include/rcube_csv2vcard.php b/program/include/rcube_csv2vcard.php
index f84108ded..bde8198ba 100644
--- a/program/include/rcube_csv2vcard.php
+++ b/program/include/rcube_csv2vcard.php
@@ -54,11 +54,11 @@ class rcube_csv2vcard
//'company_main_phone' => '',
'department' => 'department',
//'email_2_address' => '', //@TODO
- //'email_2_type' => '', //@TODO
+ //'email_2_type' => '',
//'email_3_address' => '', //@TODO
- //'email_3_type' => '', //@TODO
+ //'email_3_type' => '',
'email_address' => 'email:main',
- //'email_type' => '', //@TODO
+ //'email_type' => '',
'first_name' => 'firstname',
'gender' => 'gender',
'home_city' => 'locality:home',
@@ -155,12 +155,12 @@ class rcube_csv2vcard
//'company_main_phone' => "Company Main Phone",
'department' => "Department",
//'directory_server' => "Directory Server",
- //'email_2_address' => "E-mail 2 Address", //@TODO
- //'email_2_type' => "E-mail 2 Type", //@TODO
- //'email_3_address' => "E-mail 3 Address", //@TODO
- //'email_3_type' => "E-mail 3 Type", //@TODO
+ //'email_2_address' => "E-mail 2 Address",
+ //'email_2_type' => "E-mail 2 Type",
+ //'email_3_address' => "E-mail 3 Address",
+ //'email_3_type' => "E-mail 3 Type",
'email_address' => "E-mail Address",
- //'email_type' => "E-mail Type", //@TODO
+ //'email_type' => "E-mail Type",
'first_name' => "First Name",
'gender' => "Gender",
'home_city' => "Home City",
@@ -338,6 +338,18 @@ class rcube_csv2vcard
$contact['birthday'] = $contact['birthday-y'] .'-' .$contact['birthday-m'] . '-' . $contact['birthday-d'];
}
+ foreach (array('birthday', 'anniversary') as $key) {
+ if (!empty($contact[$key]) && $contact[$key] == '0/0/00') { // @TODO: localization?
+ unset($contact[$key]);
+ }
+ }
+
+ if (!empty($contact['gender']) && ($gender = strtolower($contact['gender']))) {
+ if (!in_array($gender, array('male', 'female'))) {
+ unset($contact['gender']);
+ }
+ }
+
// Create vcard object
$vcard = new rcube_vcard();
foreach ($contact as $name => $value) {