diff options
Diffstat (limited to 'apps/contacts')
-rw-r--r-- | apps/contacts/ajax/addcard.php | 9 | ||||
-rw-r--r-- | apps/contacts/ajax/addproperty.php | 13 | ||||
-rw-r--r-- | apps/contacts/ajax/deletebook.php | 9 | ||||
-rw-r--r-- | apps/contacts/ajax/deletecard.php | 12 | ||||
-rw-r--r-- | apps/contacts/ajax/deleteproperty.php | 16 | ||||
-rw-r--r-- | apps/contacts/ajax/getdetails.php | 13 | ||||
-rw-r--r-- | apps/contacts/ajax/setproperty.php | 15 | ||||
-rw-r--r-- | apps/contacts/ajax/showaddcard.php | 7 | ||||
-rw-r--r-- | apps/contacts/ajax/showaddproperty.php | 11 | ||||
-rw-r--r-- | apps/contacts/ajax/showsetproperty.php | 15 |
10 files changed, 44 insertions, 76 deletions
diff --git a/apps/contacts/ajax/addcard.php b/apps/contacts/ajax/addcard.php index 6005d74d144..cfae3327f56 100644 --- a/apps/contacts/ajax/addcard.php +++ b/apps/contacts/ajax/addcard.php @@ -27,14 +27,11 @@ $aid = $_POST['id']; $l10n = new OC_L10N('contacts'); // Check if we are a user -if( !OC_User::isLoggedIn()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in.')))); - exit(); -} +OC_JSON::checkLoggedIn(); $addressbook = OC_Contacts_Addressbook::find( $aid ); if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ - echo json_encode( array( 'status' => 'error', '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' => $l10n->t('This is not your addressbook.')))); // Same here (as with the contact error). Could this error be improved? exit(); } @@ -51,4 +48,4 @@ $tmpl->assign('details',$details); $tmpl->assign('id',$id); $page = $tmpl->fetchPage(); -echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id, 'page' => $page ))); +OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page ))); diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php index a311bba6e26..5a37f77f858 100644 --- a/apps/contacts/ajax/addproperty.php +++ b/apps/contacts/ajax/addproperty.php @@ -27,27 +27,24 @@ $id = $_POST['id']; $l10n = new OC_L10N('contacts'); // Check if we are a user -if( !OC_User::isLoggedIn()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in.')))); - exit(); -} +OC_JSON::checkLoggedIn(); $card = OC_Contacts_VCard::find( $id ); if( $card === false ){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Contact could not be found.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('Contact could not be found.')))); exit(); } $addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] ); if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your contact.')))); exit(); } $vcard = OC_Contacts_VCard::parse($card['carddata']); // Check if the card is valid if(is_null($vcard)){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('vCard could not be read.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('vCard could not be read.')))); exit(); } @@ -75,4 +72,4 @@ $tmpl = new OC_Template('contacts','part.property'); $tmpl->assign('property',OC_Contacts_VCard::structureProperty($property,$line)); $page = $tmpl->fetchPage(); -echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page ))); +OC_JSON::success(array('data' => array( 'page' => $page ))); diff --git a/apps/contacts/ajax/deletebook.php b/apps/contacts/ajax/deletebook.php index 38322f5c109..13be33eb5a9 100644 --- a/apps/contacts/ajax/deletebook.php +++ b/apps/contacts/ajax/deletebook.php @@ -28,16 +28,13 @@ $id = $_GET['id']; $l10n = new OC_L10N('contacts'); // Check if we are a user -if( !OC_User::isLoggedIn()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in.')))); - exit(); -} +OC_JSON::checkLoggedIn(); $addressbook = OC_Contacts_Addressbook::find( $id ); if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your contact.')))); exit(); } OC_Contacts_Addressbook::delete($id); -echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id ))); +OC_JSON::success(array('data' => array( 'id' => $id ))); diff --git a/apps/contacts/ajax/deletecard.php b/apps/contacts/ajax/deletecard.php index 7dde7d30a52..c69638320ed 100644 --- a/apps/contacts/ajax/deletecard.php +++ b/apps/contacts/ajax/deletecard.php @@ -28,23 +28,19 @@ $id = $_GET['id']; $l10n = new OC_L10N('contacts'); // Check if we are a user -if( !OC_User::isLoggedIn()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in.')))); - exit(); -} - +OC_JSON::checkLoggedIn(); $card = OC_Contacts_VCard::find( $id ); if( $card === false ){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Contact could not be found.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('Contact could not be found.')))); exit(); } $addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] ); if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your contact.')))); exit(); } OC_Contacts_VCard::delete($id); -echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id ))); +OC_JSON::success(array('data' => array( 'id' => $id ))); diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php index 07cea0b53e1..40b765cf845 100644 --- a/apps/contacts/ajax/deleteproperty.php +++ b/apps/contacts/ajax/deleteproperty.php @@ -30,28 +30,24 @@ $checksum = $_GET['checksum']; $l10n = new OC_L10N('contacts'); // Check if we are a user -if( !OC_User::isLoggedIn()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in.')))); - exit(); -} - +OC_JSON::checkLoggedIn(); $card = OC_Contacts_VCard::find( $id ); if( $card === false ){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Contact could not be found.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('Contact could not be found.')))); exit(); } $addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] ); if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your contact.')))); exit(); } $vcard = OC_Contacts_VCard::parse($card['carddata']); // Check if the card is valid if(is_null($vcard)){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('vCard could not be read.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('vCard could not be read.')))); exit(); } @@ -62,11 +58,11 @@ for($i=0;$i<count($vcard->children);$i++){ } } if(is_null($line)){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Information about vCard is incorrect. Please reload the page.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('Information about vCard is incorrect. Please reload the page.')))); exit(); } unset($vcard->children[$line]); OC_Contacts_VCard::edit($id,$vcard->serialize()); -echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id ))); +OC_JSON::success(array('data' => array( 'id' => $id ))); diff --git a/apps/contacts/ajax/getdetails.php b/apps/contacts/ajax/getdetails.php index ab1f1d66f5e..47d88a771e6 100644 --- a/apps/contacts/ajax/getdetails.php +++ b/apps/contacts/ajax/getdetails.php @@ -28,28 +28,25 @@ $id = $_GET['id']; $l10n = new OC_L10N('contacts'); // Check if we are a user -if( !OC_User::isLoggedIn()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in.')))); - exit(); -} +OC_JSON::checkLoggedIn(); $card = OC_Contacts_VCard::find( $id ); if( $card === false ){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Contact could not be found.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('Contact could not be found.')))); exit(); } $addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] ); if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your contact.')))); exit(); } $vcard = OC_Contacts_VCard::parse($card['carddata']); // Check if the card is valid if(is_null($vcard)){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('vCard could not be read.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('vCard could not be read.')))); exit(); } @@ -59,4 +56,4 @@ $tmpl->assign('details',$details); $tmpl->assign('id',$id); $page = $tmpl->fetchPage(); -echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id, 'page' => $page ))); +OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page ))); diff --git a/apps/contacts/ajax/setproperty.php b/apps/contacts/ajax/setproperty.php index 9178a6aac9f..b4fc2162d90 100644 --- a/apps/contacts/ajax/setproperty.php +++ b/apps/contacts/ajax/setproperty.php @@ -28,27 +28,24 @@ $checksum = $_POST['checksum']; $l10n = new OC_L10N('contacts'); // Check if we are a user -if( !OC_User::isLoggedIn()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in.')))); - exit(); -} +OC_JSON::checkLoggedIn(); $card = OC_Contacts_VCard::find( $id ); if( $card === false ){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Contact could not be found.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('Contact could not be found.')))); exit(); } $addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] ); if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your contact.')))); exit(); } $vcard = OC_Contacts_VCard::parse($card['carddata']); // Check if the card is valid if(is_null($vcard)){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('vCard could not be read.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('vCard could not be read.')))); exit(); } @@ -59,7 +56,7 @@ for($i=0;$i<count($vcard->children);$i++){ } } if(is_null($line)){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Information about vCard is incorrect. Please reload the page.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('Information about vCard is incorrect. Please reload the page.')))); exit(); } @@ -100,4 +97,4 @@ $tmpl = new OC_Template('contacts','part.property'); $tmpl->assign('property',OC_Contacts_VCard::structureProperty($vcard->children[$line],$line)); $page = $tmpl->fetchPage(); -echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page, 'line' => $line, 'oldchecksum' => $_POST['checksum'] ))); +OC_JSON::success(array('data' => array( 'page' => $page, 'line' => $line, 'oldchecksum' => $_POST['checksum'] ))); diff --git a/apps/contacts/ajax/showaddcard.php b/apps/contacts/ajax/showaddcard.php index 89c78fcdf54..58567392d7c 100644 --- a/apps/contacts/ajax/showaddcard.php +++ b/apps/contacts/ajax/showaddcard.php @@ -26,14 +26,11 @@ require_once('../../../lib/base.php'); $l10n = new OC_L10N('contacts'); // Check if we are a user -if( !OC_User::isLoggedIn()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in.')))); - exit(); -} +OC_JSON::checkLoggedIn(); $addressbooks = OC_Contacts_Addressbook::all(OC_USER::getUser()); $tmpl = new OC_Template('contacts','part.addcardform'); $tmpl->assign('addressbooks',$addressbooks); $page = $tmpl->fetchPage(); -echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page ))); +OC_JSON::success(array('data' => array( 'page' => $page ))); diff --git a/apps/contacts/ajax/showaddproperty.php b/apps/contacts/ajax/showaddproperty.php index 718478d42bf..0d01b37d8ef 100644 --- a/apps/contacts/ajax/showaddproperty.php +++ b/apps/contacts/ajax/showaddproperty.php @@ -27,20 +27,17 @@ $id = $_GET['id']; $l10n = new OC_L10N('contacts'); // Check if we are a user -if( !OC_User::isLoggedIn()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in.')))); - exit(); -} +OC_JSON::checkLoggedIn(); $card = OC_Contacts_VCard::find( $id ); if( $card === false ){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Contact could not be found.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('Contact could not be found.')))); exit(); } $addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] ); if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your contact.')))); exit(); } @@ -48,4 +45,4 @@ $tmpl = new OC_Template('contacts','part.addpropertyform'); $tmpl->assign('id',$id); $page = $tmpl->fetchPage(); -echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page ))); +OC_JSON::success(array('data' => array( 'page' => $page ))); diff --git a/apps/contacts/ajax/showsetproperty.php b/apps/contacts/ajax/showsetproperty.php index 77b90ea8cc4..0b30a8e68ec 100644 --- a/apps/contacts/ajax/showsetproperty.php +++ b/apps/contacts/ajax/showsetproperty.php @@ -28,27 +28,24 @@ $checksum = $_GET['checksum']; $l10n = new OC_L10N('contacts'); // Check if we are a user -if( !OC_User::isLoggedIn()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in.')))); - exit(); -} +OC_JSON::checkLoggedIn(); $card = OC_Contacts_VCard::find( $id ); if( $card === false ){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Contact could not be found.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('Contact could not be found.')))); exit(); } $addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] ); if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your contact.')))); exit(); } $vcard = OC_Contacts_VCard::parse($card['carddata']); // Check if the card is valid if(is_null($vcard)){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('vCard could not be read.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('vCard could not be read.')))); exit(); } @@ -59,7 +56,7 @@ for($i=0;$i<count($vcard->children);$i++){ } } if(is_null($line)){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Information about vCard is incorrect. Please reload the page.')))); + OC_JSON::error(array('data' => array( 'message' => $l10n->t('Information about vCard is incorrect. Please reload the page.')))); exit(); } @@ -70,4 +67,4 @@ $tmpl->assign('checksum',$checksum); $tmpl->assign('property',OC_Contacts_VCard::structureProperty($vcard->children[$line])); $page = $tmpl->fetchPage(); -echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page ))); +OC_JSON::success(array('data' => array( 'page' => $page ))); |