summaryrefslogtreecommitdiffstats
path: root/apps/contacts/ajax
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2011-12-05 21:51:25 +0100
committerBart Visscher <bartv@thisnet.nl>2011-12-07 20:40:58 +0100
commit247146f7036984e0ae7a6719e8adfca6c2251079 (patch)
tree9e3d221d072818ba1935ab6c69074244580be7d5 /apps/contacts/ajax
parentc67ac46b6c3b333c7f16cbdc8df7b9a6b4f3fb1b (diff)
downloadnextcloud-server-247146f7036984e0ae7a6719e8adfca6c2251079.tar.gz
nextcloud-server-247146f7036984e0ae7a6719e8adfca6c2251079.zip
Contacts: refactor rendering of part.details template
Diffstat (limited to 'apps/contacts/ajax')
-rw-r--r--apps/contacts/ajax/addcard.php20
-rw-r--r--apps/contacts/ajax/getdetails.php26
-rw-r--r--apps/contacts/ajax/setproperty.php4
-rw-r--r--apps/contacts/ajax/showaddcard.php6
-rw-r--r--apps/contacts/ajax/showsetproperty.php4
5 files changed, 11 insertions, 49 deletions
diff --git a/apps/contacts/ajax/addcard.php b/apps/contacts/ajax/addcard.php
index 8d192641dbd..9a52b26ed59 100644
--- a/apps/contacts/ajax/addcard.php
+++ b/apps/contacts/ajax/addcard.php
@@ -23,16 +23,14 @@
// Init owncloud
require_once('../../../lib/base.php');
-$aid = $_POST['id'];
-$l10n = new OC_L10N('contacts');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
+$aid = $_POST['id'];
$addressbook = OC_Contacts_Addressbook::find( $aid );
if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your addressbook.')))); // Same here (as with the contact error). Could this error be improved?
+ OC_JSON::error(array('data' => array( 'message' => OC_Contacts_App::$l10n->t('This is not your addressbook.')))); // Same here (as with the contact error). Could this error be improved?
exit();
}
@@ -68,16 +66,4 @@ foreach( $add as $propname){
}
$id = OC_Contacts_VCard::add($aid,$vcard->serialize());
-$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
-$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
-
-$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);
-$tmpl->assign('adr_types',$adr_types);
-$tmpl->assign('phone_types',$phone_types);
-$page = $tmpl->fetchPage();
-
-OC_JSON::success(array('data' => array( 'id' => $id, 'name' => $name, 'page' => $page )));
+OC_Contacts_App::renderDetails($id, $vcard);
diff --git a/apps/contacts/ajax/getdetails.php b/apps/contacts/ajax/getdetails.php
index eb1f20ee75e..e480bce4cb4 100644
--- a/apps/contacts/ajax/getdetails.php
+++ b/apps/contacts/ajax/getdetails.php
@@ -23,15 +23,11 @@
// Init owncloud
require_once('../../../lib/base.php');
-$id = $_GET['id'];
-
-$l10n = new OC_L10N('contacts');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
-
+$id = $_GET['id'];
$card = OC_Contacts_VCard::find( $id );
if( $card === false ){
OC_JSON::error(array('data' => array( 'message' => $l10n->t('Contact could not be found.'))));
@@ -51,22 +47,4 @@ if(is_null($vcard)){
exit();
}
-$property_types = array(
- 'ADR' => $l10n->t('Address'),
- 'TEL' => $l10n->t('Telephone'),
- 'EMAIL' => $l10n->t('Email'),
- 'ORG' => $l10n->t('Organization'),
-);
-$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
-$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
-
-$details = OC_Contacts_VCard::structureContact($vcard);
-$tmpl = new OC_Template('contacts','part.details');
-$tmpl->assign('details',$details);
-$tmpl->assign('id',$id);
-$tmpl->assign('property_types',$property_types);
-$tmpl->assign('adr_types',$adr_types);
-$tmpl->assign('phone_types',$phone_types);
-$page = $tmpl->fetchPage();
-
-OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page )));
+OC_Contacts_App::renderDetails($id, $vcard);
diff --git a/apps/contacts/ajax/setproperty.php b/apps/contacts/ajax/setproperty.php
index 2edfa5b452f..e636cc5c1bd 100644
--- a/apps/contacts/ajax/setproperty.php
+++ b/apps/contacts/ajax/setproperty.php
@@ -104,8 +104,8 @@ $checksum = md5($vcard->children[$line]->serialize());
OC_Contacts_VCard::edit($id,$vcard->serialize());
-$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
-$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
+$adr_types = OC_Contacts_App::getTypesOfProperty($l10n, 'ADR');
+$phone_types = OC_Contacts_App::getTypesOfProperty($l10n, 'TEL');
if ($vcard->children[$line]->name == 'FN'){
$tmpl = new OC_Template('contacts','part.property.FN');
diff --git a/apps/contacts/ajax/showaddcard.php b/apps/contacts/ajax/showaddcard.php
index 98367758fd4..a2a9398bde5 100644
--- a/apps/contacts/ajax/showaddcard.php
+++ b/apps/contacts/ajax/showaddcard.php
@@ -23,14 +23,12 @@
// Init owncloud
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('contacts');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
-$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
-$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
+$adr_types = OC_Contacts_App::getTypesOfProperty(OC_Contacts_App::$l10n, 'ADR');
+$phone_types = OC_Contacts_App::getTypesOfProperty(OC_Contacts_App::$l10n, 'TEL');
$addressbooks = OC_Contacts_Addressbook::all(OC_USER::getUser());
$tmpl = new OC_Template('contacts','part.addcardform');
diff --git a/apps/contacts/ajax/showsetproperty.php b/apps/contacts/ajax/showsetproperty.php
index 1cf65417809..30d0f5d817c 100644
--- a/apps/contacts/ajax/showsetproperty.php
+++ b/apps/contacts/ajax/showsetproperty.php
@@ -61,8 +61,8 @@ if(is_null($line)){
exit();
}
-$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
-$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
+$adr_types = OC_Contacts_App::getTypesOfProperty($l10n, 'ADR');
+$phone_types = OC_Contacts_App::getTypesOfProperty($l10n, 'TEL');
$tmpl = new OC_Template('contacts','part.setpropertyform');
$tmpl->assign('id',$id);