summaryrefslogtreecommitdiffstats
path: root/apps/contacts/ajax
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2011-12-16 17:42:07 +0100
committerThomas Tanghus <thomas@tanghus.net>2011-12-16 17:42:07 +0100
commitfeeb0c742a57eb542f6e904dd4c8b5310bcc066a (patch)
tree8d422f84371d865dcdcdc60d95d4c3fcccd8b8e2 /apps/contacts/ajax
parent59ad0a6c9c9862792ec92f9ab53dfc30d54867fa (diff)
downloadnextcloud-server-feeb0c742a57eb542f6e904dd4c8b5310bcc066a.tar.gz
nextcloud-server-feeb0c742a57eb542f6e904dd4c8b5310bcc066a.zip
Misc. changes after review by bartv.
Diffstat (limited to 'apps/contacts/ajax')
-rw-r--r--apps/contacts/ajax/activation.php7
-rw-r--r--apps/contacts/ajax/addbook.php4
-rw-r--r--apps/contacts/ajax/chooseaddressbook.php4
-rw-r--r--apps/contacts/ajax/contacts.php8
-rw-r--r--apps/contacts/ajax/createaddressbook.php2
-rw-r--r--apps/contacts/ajax/editaddressbook.php6
-rw-r--r--apps/contacts/ajax/showaddcard.php2
-rw-r--r--apps/contacts/ajax/updateaddressbook.php2
8 files changed, 13 insertions, 22 deletions
diff --git a/apps/contacts/ajax/activation.php b/apps/contacts/ajax/activation.php
index 49aaac97287..f4a2c94a148 100644
--- a/apps/contacts/ajax/activation.php
+++ b/apps/contacts/ajax/activation.php
@@ -8,16 +8,15 @@
*/
require_once ("../../../lib/base.php");
-if(!OC_USER::isLoggedIn()) {
- die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
-}
+OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$bookid = $_POST['bookid'];
OC_Contacts_Addressbook::setActive($bookid, $_POST['active']);
-$book = OC_Contacts_Addressbook::find($bookid);
+$book = OC_Contacts_App::getAddressbook($bookid);
/* is there an OC_JSON::error() ? */
OC_JSON::success(array(
'active' => OC_Contacts_Addressbook::isActive($bookid),
'bookid' => $bookid,
+ 'book' => $book,
));
diff --git a/apps/contacts/ajax/addbook.php b/apps/contacts/ajax/addbook.php
index d8e5a0ecd59..36acb9af391 100644
--- a/apps/contacts/ajax/addbook.php
+++ b/apps/contacts/ajax/addbook.php
@@ -8,9 +8,7 @@
require_once('../../../lib/base.php');
$l10n = new OC_L10N('contacts');
-if(!OC_USER::isLoggedIn()) {
- die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
-}
+OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$book = array(
'id' => 'new',
diff --git a/apps/contacts/ajax/chooseaddressbook.php b/apps/contacts/ajax/chooseaddressbook.php
index f74b580eae7..b0a10bb3118 100644
--- a/apps/contacts/ajax/chooseaddressbook.php
+++ b/apps/contacts/ajax/chooseaddressbook.php
@@ -8,9 +8,7 @@
require_once('../../../lib/base.php');
$l10n = new OC_L10N('contacts');
-if(!OC_USER::isLoggedIn()) {
- die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
-}
+OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$output = new OC_TEMPLATE("contacts", "part.chooseaddressbook");
diff --git a/apps/contacts/ajax/contacts.php b/apps/contacts/ajax/contacts.php
index 3c3bb5fe955..b34cf414249 100644
--- a/apps/contacts/ajax/contacts.php
+++ b/apps/contacts/ajax/contacts.php
@@ -7,16 +7,14 @@
*/
function contacts_namesort($a,$b){
- return strcmp($a['fullname'],$b['fullname']);
+ return strcasecmp($a['fullname'],$b['fullname']);
}
require_once('../../../lib/base.php');
-if(!OC_USER::isLoggedIn()) {
- die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
-}
+OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
-$addressbooks = OC_Contacts_Addressbook::activeAddressbooks(OC_User::getUser());
+$addressbooks = OC_Contacts_Addressbook::active(OC_User::getUser());
$contacts = array();
foreach( $addressbooks as $addressbook ){
$addressbookcontacts = OC_Contacts_VCard::all($addressbook['id']);
diff --git a/apps/contacts/ajax/createaddressbook.php b/apps/contacts/ajax/createaddressbook.php
index 8fec07ebcae..f94ad34e8dc 100644
--- a/apps/contacts/ajax/createaddressbook.php
+++ b/apps/contacts/ajax/createaddressbook.php
@@ -17,7 +17,7 @@ OC_JSON::checkAppEnabled('contacts');
$userid = OC_User::getUser();
$bookid = OC_Contacts_Addressbook::add($userid, $_POST['name'], null);
OC_Contacts_Addressbook::setActive($bookid, 1);
-$addressbook = OC_Contacts_Addressbook::find($bookid);
+$addressbook = OC_Contacts_App::getAddressbook($bookid);
$tmpl = new OC_Template('contacts', 'part.chooseaddressbook.rowfields');
$tmpl->assign('addressbook', $addressbook);
OC_JSON::success(array(
diff --git a/apps/contacts/ajax/editaddressbook.php b/apps/contacts/ajax/editaddressbook.php
index abdad09dea0..ced673ce807 100644
--- a/apps/contacts/ajax/editaddressbook.php
+++ b/apps/contacts/ajax/editaddressbook.php
@@ -8,11 +8,9 @@
require_once('../../../lib/base.php');
$l10n = new OC_L10N('contacts');
-if(!OC_USER::isLoggedIn()) {
- die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
-}
+OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
-$addressbook = OC_Contacts_Addressbook::find($_GET['bookid']);
+$addressbook = OC_Contacts_App::getAddressbook($_GET['bookid']);
$tmpl = new OC_Template("contacts", "part.editaddressbook");
$tmpl->assign('new', false);
$tmpl->assign('addressbook', $addressbook);
diff --git a/apps/contacts/ajax/showaddcard.php b/apps/contacts/ajax/showaddcard.php
index 92e24216c5e..54592c89c0d 100644
--- a/apps/contacts/ajax/showaddcard.php
+++ b/apps/contacts/ajax/showaddcard.php
@@ -30,7 +30,7 @@ OC_JSON::checkAppEnabled('contacts');
$adr_types = OC_Contacts_App::getTypesOfProperty('ADR');
$phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
-$addressbooks = OC_Contacts_Addressbook::allAddressbooks(OC_USER::getUser());
+$addressbooks = OC_Contacts_Addressbook::all(OC_USER::getUser());
$tmpl = new OC_Template('contacts','part.addcardform');
$tmpl->assign('addressbooks',$addressbooks);
$tmpl->assign('adr_types',$adr_types);
diff --git a/apps/contacts/ajax/updateaddressbook.php b/apps/contacts/ajax/updateaddressbook.php
index 011dfc35d1a..516736cc502 100644
--- a/apps/contacts/ajax/updateaddressbook.php
+++ b/apps/contacts/ajax/updateaddressbook.php
@@ -17,7 +17,7 @@ OC_JSON::checkAppEnabled('contacts');
$bookid = $_POST['id'];
OC_Contacts_Addressbook::edit($bookid, $_POST['name'], null);
OC_Contacts_Addressbook::setActive($bookid, $_POST['active']);
-$addressbook = OC_Contacts_Addressbook::find($bookid);
+$addressbook = OC_Contacts_App::getAddressbook($bookid);
$tmpl = new OC_Template('contacts', 'part.chooseaddressbook.rowfields');
$tmpl->assign('addressbook', $addressbook);
OC_JSON::success(array(