diff options
-rw-r--r-- | apps/contacts/ajax/activation.php | 9 | ||||
-rw-r--r-- | apps/contacts/ajax/addcard.php | 7 | ||||
-rw-r--r-- | apps/contacts/ajax/addproperty.php | 6 | ||||
-rw-r--r-- | apps/contacts/ajax/createaddressbook.php | 14 | ||||
-rw-r--r-- | apps/contacts/ajax/deleteproperty.php | 8 | ||||
-rw-r--r-- | apps/contacts/ajax/setproperty.php | 7 | ||||
-rw-r--r-- | apps/contacts/ajax/updateaddressbook.php | 17 | ||||
-rw-r--r-- | apps/contacts/js/interface.js | 22 | ||||
-rw-r--r-- | apps/contacts/l10n/xgettextfiles | 21 | ||||
-rw-r--r-- | apps/contacts/lib/addressbook.php | 1 | ||||
-rw-r--r-- | apps/contacts/lib/vcard.php | 2 | ||||
-rw-r--r-- | apps/contacts/templates/index.php | 2 | ||||
-rw-r--r-- | apps/contacts/templates/part.addcardform.php | 10 | ||||
-rw-r--r-- | apps/contacts/templates/part.chooseaddressbook.rowfields.php | 2 | ||||
-rw-r--r-- | apps/contacts/templates/part.editaddressbook.php | 2 | ||||
-rw-r--r-- | apps/contacts/templates/settings.php | 4 |
16 files changed, 101 insertions, 33 deletions
diff --git a/apps/contacts/ajax/activation.php b/apps/contacts/ajax/activation.php index f4a2c94a148..fda63a528a4 100644 --- a/apps/contacts/ajax/activation.php +++ b/apps/contacts/ajax/activation.php @@ -10,10 +10,17 @@ require_once ("../../../lib/base.php"); OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); +$l=new OC_L10N('contacts'); + $bookid = $_POST['bookid']; -OC_Contacts_Addressbook::setActive($bookid, $_POST['active']); +if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) { + OC_JSON::error(array('data' => array('message' => $l->t('Error (de)activating addressbook.')))); + OC_Log::write('contacts','ajax/activation.php: Error activating addressbook: '.$bookid, OC_Log::ERROR); + exit(); +} $book = OC_Contacts_App::getAddressbook($bookid); + /* is there an OC_JSON::error() ? */ OC_JSON::success(array( 'active' => OC_Contacts_Addressbook::isActive($bookid), diff --git a/apps/contacts/ajax/addcard.php b/apps/contacts/ajax/addcard.php index 9d9a99de33c..7e47659d23b 100644 --- a/apps/contacts/ajax/addcard.php +++ b/apps/contacts/ajax/addcard.php @@ -26,6 +26,7 @@ require_once('../../../lib/base.php'); // Check if we are a user OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); +$l=new OC_L10N('contacts'); $aid = $_POST['id']; $addressbook = OC_Contacts_App::getAddressbook( $aid ); @@ -74,5 +75,11 @@ 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); + exit(); +} +// NOTE: Why is this in OC_Contacts_App? OC_Contacts_App::renderDetails($id, $vcard); diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php index 74f1c3d0e9e..6e3ba3566c0 100644 --- a/apps/contacts/ajax/addproperty.php +++ b/apps/contacts/ajax/addproperty.php @@ -61,7 +61,11 @@ foreach ($parameters as $key=>$element) { } } -OC_Contacts_VCard::edit($id,$vcard->serialize()); +if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) { + OC_JSON::error(array('data' => array('message' => $l->t('Error adding contact property.')))); + OC_Log::write('contacts','ajax/addproperty.php: Error updating contact property: '.$name, OC_Log::ERROR); + exit(); +} $adr_types = OC_Contacts_App::getTypesOfProperty('ADR'); $phone_types = OC_Contacts_App::getTypesOfProperty('TEL'); diff --git a/apps/contacts/ajax/createaddressbook.php b/apps/contacts/ajax/createaddressbook.php index f94ad34e8dc..edcf794f497 100644 --- a/apps/contacts/ajax/createaddressbook.php +++ b/apps/contacts/ajax/createaddressbook.php @@ -1,6 +1,6 @@ <?php /** - * Copyright (c) 2011 Thomas Tanghus <thomas@tanghus.net> + * Copyright (c) 2011-2012 Thomas Tanghus <thomas@tanghus.net> * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl> * This file is licensed under the Affero General Public License version 3 or * later. @@ -16,7 +16,17 @@ OC_JSON::checkAppEnabled('contacts'); $userid = OC_User::getUser(); $bookid = OC_Contacts_Addressbook::add($userid, $_POST['name'], null); -OC_Contacts_Addressbook::setActive($bookid, 1); +if(!$bookid) { + OC_JSON::error(array('data' => array('message' => $l->t('Error adding addressbook.')))); + OC_Log::write('contacts','ajax/createaddressbook.php: Error adding addressbook: '.$_POST['name'], OC_Log::ERROR); + exit(); +} + +if(!OC_Contacts_Addressbook::setActive($bookid, 1)) { + OC_JSON::error(array('data' => array('message' => $l->t('Error activating addressbook.')))); + OC_Log::write('contacts','ajax/createaddressbook.php: Error activating addressbook: '.$bookid, OC_Log::ERROR); + //exit(); +} $addressbook = OC_Contacts_App::getAddressbook($bookid); $tmpl = new OC_Template('contacts', 'part.chooseaddressbook.rowfields'); $tmpl->assign('addressbook', $addressbook); diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php index f69735e61c6..89cf292f4f8 100644 --- a/apps/contacts/ajax/deleteproperty.php +++ b/apps/contacts/ajax/deleteproperty.php @@ -26,6 +26,7 @@ require_once('../../../lib/base.php'); // Check if we are a user OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); +$l10n = new OC_L10N('contacts'); $id = $_GET['id']; $checksum = $_GET['checksum']; @@ -35,5 +36,10 @@ $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); unset($vcard->children[$line]); -OC_Contacts_VCard::edit($id,$vcard->serialize()); +if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) { + OC_JSON::error(array('data' => array('message' => $l->t('Error deleting contact property.')))); + OC_Log::write('contacts','ajax/deleteproperty.php: Error deleting contact property', OC_Log::ERROR); + exit(); +} + OC_JSON::success(array('data' => array( 'id' => $id ))); diff --git a/apps/contacts/ajax/setproperty.php b/apps/contacts/ajax/setproperty.php index bcc4c161cc0..e0cd70236c8 100644 --- a/apps/contacts/ajax/setproperty.php +++ b/apps/contacts/ajax/setproperty.php @@ -72,9 +72,14 @@ foreach($missingparameters as $i){ } // Do checksum and be happy +// NOTE: This checksum is not used..? $checksum = md5($vcard->children[$line]->serialize()); -OC_Contacts_VCard::edit($id,$vcard->serialize()); +if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) { + OC_JSON::error(array('data' => array('message' => $l->t('Error updating contact property.')))); + OC_Log::write('contacts','ajax/setproperty.php: Error updating contact property: '.$value, OC_Log::ERROR); + exit(); +} $adr_types = OC_Contacts_App::getTypesOfProperty('ADR'); $phone_types = OC_Contacts_App::getTypesOfProperty('TEL'); diff --git a/apps/contacts/ajax/updateaddressbook.php b/apps/contacts/ajax/updateaddressbook.php index 516736cc502..7d9e2aea917 100644 --- a/apps/contacts/ajax/updateaddressbook.php +++ b/apps/contacts/ajax/updateaddressbook.php @@ -1,6 +1,6 @@ <?php /** - * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl> + * Copyright (c) 2011-2012 Thomas Tanghus <thomas@tanghus.net> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. @@ -15,8 +15,19 @@ OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); $bookid = $_POST['id']; -OC_Contacts_Addressbook::edit($bookid, $_POST['name'], null); -OC_Contacts_Addressbook::setActive($bookid, $_POST['active']); + +if(!OC_Contacts_Addressbook::edit($bookid, $_POST['name'], null)) { + OC_JSON::error(array('data' => array('message' => $l->t('Error updating addressbook.')))); + OC_Log::write('contacts','ajax/updateaddressbook.php: Error adding addressbook: ', OC_Log::ERROR); + //exit(); +} + +if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) { + OC_JSON::error(array('data' => array('message' => $l->t('Error (de)activating addressbook.')))); + OC_Log::write('contacts','ajax/updateaddressbook.php: Error (de)activating addressbook: '.$bookid, OC_Log::ERROR); + //exit(); +} + $addressbook = OC_Contacts_App::getAddressbook($bookid); $tmpl = new OC_Template('contacts', 'part.chooseaddressbook.rowfields'); $tmpl->assign('addressbook', $addressbook); diff --git a/apps/contacts/js/interface.js b/apps/contacts/js/interface.js index 741483633da..8a1de3051a6 100644 --- a/apps/contacts/js/interface.js +++ b/apps/contacts/js/interface.js @@ -106,7 +106,7 @@ Contacts={ Contacts.UI.Contacts.update(); Contacts.UI.Addressbooks.overview(); } else { - Contacts.UI.messageBox('Error', data.message); + Contacts.UI.messageBox(t('contacts', 'Error'), data.message); //alert('Error: ' + data.message); } }); @@ -145,7 +145,7 @@ Contacts={ $('#contacts').html(jsondata.data.page); } else{ - Contacts.UI.messageBox('Error',jsondata.data.message); + Contacts.UI.messageBox(t('contacts', 'Error'),jsondata.data.message); //alert(jsondata.data.message); } }); @@ -186,7 +186,7 @@ $(document).ready(function(){ $('#leftcontent li[data-id="'+jsondata.data.id+'"]').addClass('active'); } else{ - Contacts.UI.messageBox('Error', jsondata.data.message); + Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); //alert(jsondata.data.message); } }); @@ -206,7 +206,7 @@ $(document).ready(function(){ $('#rightcontent').empty(); } else{ - Contacts.UI.messageBox('Error', jsondata.data.message); + Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); //alert(jsondata.data.message); } }); @@ -225,7 +225,7 @@ $(document).ready(function(){ $('#contacts_addproperty').hide(); } else{ - Contacts.UI.messageBox('Error', jsondata.data.message); + Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); alert('From handler: '+jsondata.data.message); } }); @@ -258,7 +258,7 @@ $(document).ready(function(){ $('#contacts_addpropertyform').before(jsondata.data.page); } else{ - Contacts.UI.messageBox('Error', jsondata.data.message); + Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); } }, 'json'); return false; @@ -283,7 +283,7 @@ $(document).ready(function(){ .find('select').chosen(); } else{ - Contacts.UI.messageBox('Error', jsondata.data.message); + Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); //alert(jsondata.data.message); } }); @@ -313,7 +313,7 @@ $(document).ready(function(){ } } else{ - Contacts.UI.messageBox('Error', jsondata.data.message); + Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); //alert(jsondata.data.message); } }, 'json'); @@ -332,7 +332,7 @@ $(document).ready(function(){ .find('select').chosen(); } else{ - Contacts.UI.messageBox('Error', jsondata.data.message); + Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); //alert(jsondata.data.message); } }); @@ -348,7 +348,7 @@ $(document).ready(function(){ $('.contacts_property[data-checksum="'+jsondata.data.oldchecksum+'"]').replaceWith(jsondata.data.page); } else{ - Contacts.UI.messageBox('Error', jsondata.data.message); + Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); //alert(jsondata.data.message); } },'json'); @@ -363,7 +363,7 @@ $(document).ready(function(){ $('.contacts_property[data-checksum="'+checksum+'"]').remove(); } else{ - Contacts.UI.messageBox('Error', jsondata.data.message); + Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); //alert(jsondata.data.message); } }); diff --git a/apps/contacts/l10n/xgettextfiles b/apps/contacts/l10n/xgettextfiles new file mode 100644 index 00000000000..91d5da46db0 --- /dev/null +++ b/apps/contacts/l10n/xgettextfiles @@ -0,0 +1,21 @@ +../appinfo/app.php +../ajax/activation.php +../ajax/addbook.php +../ajax/addcard.php +../ajax/addproperty.php +../ajax/createaddressbook.php +../ajax/deletebook.php +../ajax/deleteproperty.php +../ajax/getdetails.php +../ajax/setproperty.php +../ajax/updateaddressbook.php +../lib/app.php +../templates/index.php +../templates/part.addcardform.php +../templates/part.chooseaddressbook.php +../templates/part.chooseaddressbook.rowfields.php +../templates/part.details.php +../templates/part.editaddressbook.php +../templates/part.property.php +../templates/part.setpropertyform.php +../templates/settings.php diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php index 41d488c09f9..052c19e55fe 100644 --- a/apps/contacts/lib/addressbook.php +++ b/apps/contacts/lib/addressbook.php @@ -256,6 +256,7 @@ class OC_Contacts_Addressbook{ * @return boolean */ public static function delete($id){ + // FIXME: There's no error checking at all. self::setActive($id, false); $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_addressbooks WHERE id = ?' ); $stmt->execute(array($id)); diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php index 726927013c6..c61f0dfc114 100644 --- a/apps/contacts/lib/vcard.php +++ b/apps/contacts/lib/vcard.php @@ -240,6 +240,7 @@ class OC_Contacts_VCard{ * @return boolean */ public static function delete($id){ + // FIXME: Add error checking. $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE id = ?' ); $stmt->execute(array($id)); @@ -261,6 +262,7 @@ class OC_Contacts_VCard{ * @return boolean */ public static function deleteFromDAVData($aid,$uri){ + // FIXME: Add error checking. Deleting a card gives an Kontact/Akonadi error. $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri=?' ); $stmt->execute(array($aid,$uri)); diff --git a/apps/contacts/templates/index.php b/apps/contacts/templates/index.php index d548f17172d..5d9c312712f 100644 --- a/apps/contacts/templates/index.php +++ b/apps/contacts/templates/index.php @@ -4,7 +4,7 @@ <div id="controls"> <form> <input type="button" id="contacts_newcontact" value="<?php echo $l->t('Add Contact'); ?>"> - <input type="button" id="chooseaddressbook" value="<?php echo $l->t('Address Books'); ?>"> + <input type="button" id="chooseaddressbook" value="<?php echo $l->t('Addressbooks'); ?>"> </form> </div> <div id="leftcontent" class="leftcontent"> diff --git a/apps/contacts/templates/part.addcardform.php b/apps/contacts/templates/part.addcardform.php index 510096a9e81..53b32188ddf 100644 --- a/apps/contacts/templates/part.addcardform.php +++ b/apps/contacts/templates/part.addcardform.php @@ -5,7 +5,7 @@ <fieldset class="inputs"> <dl class="form"> <dt> - <label class="label" for="id"><?php echo $l->t('Group'); ?></label> + <label class="label" for="id"><?php echo $l->t('Addressbook'); ?></label> </dt> <dd> <select name="id" size="1"> @@ -106,11 +106,5 @@ </dd> </dl> </fieldset> - <fieldset class="buttons"> - <ol> - <li class="commit button"> - <input class="create" type="submit" name="submit" value="<?php echo $l->t('Create Contact'); ?>"> - </li> - </ol> - </fieldset> + <input class="create" type="submit" name="submit" value="<?php echo $l->t('Create Contact'); ?>"> </form> diff --git a/apps/contacts/templates/part.chooseaddressbook.rowfields.php b/apps/contacts/templates/part.chooseaddressbook.rowfields.php index f612e39ecaf..0cbfe2bf803 100644 --- a/apps/contacts/templates/part.chooseaddressbook.rowfields.php +++ b/apps/contacts/templates/part.chooseaddressbook.rowfields.php @@ -1,5 +1,5 @@ <?php - + // FIXME: Make this readable. echo "<td width=\"20px\"><input id=\"active_" . $_['addressbook']["id"] . "\" type=\"checkbox\" onClick=\"Contacts.UI.Addressbooks.activation(this, " . $_['addressbook']["id"] . ")\"" . (OC_Contacts_Addressbook::isActive($_['addressbook']["id"]) ? ' checked="checked"' : '') . "></td>"; echo "<td><label for=\"active_" . $_['addressbook']["id"] . "\">" . $_['addressbook']["displayname"] . "</label></td>"; echo "<td width=\"20px\"><a href=\"#\" onclick=\"Contacts.UI.showCardDAVUrl('" . OC_User::getUser() . "', '" . $_['addressbook']["uri"] . "');\" title=\"" . $l->t("CardDav Link") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/public.svg\"></a></td><td width=\"20px\"><a href=\"export.php?bookid=" . $_['addressbook']["id"] . "\" title=\"" . $l->t("Download") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/download.svg\"></a></td><td width=\"20px\"><a href=\"#\" title=\"" . $l->t("Edit") . "\" class=\"action\" onclick=\"Contacts.UI.Addressbooks.editAddressbook(this, " . $_['addressbook']["id"] . ");\"><img class=\"svg action\" src=\"../../core/img/actions/rename.svg\"></a></td><td width=\"20px\"><a href=\"#\" onclick=\"Contacts.UI.Addressbooks.deleteAddressbook('" . $_['addressbook']["id"] . "');\" title=\"" . $l->t("Delete") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/delete.svg\"></a></td>"; diff --git a/apps/contacts/templates/part.editaddressbook.php b/apps/contacts/templates/part.editaddressbook.php index cb1371731b1..48fe5c3b378 100644 --- a/apps/contacts/templates/part.editaddressbook.php +++ b/apps/contacts/templates/part.editaddressbook.php @@ -6,7 +6,7 @@ * See the COPYING-README file. */ ?> -<td id="<?php echo $_['new'] ? 'new' : 'edit' ?>addressbook_dialog" title="<?php echo $_['new'] ? $l->t("New Address Book") : $l->t("Edit Address Book"); ?>" colspan="6"> +<td id="<?php echo $_['new'] ? 'new' : 'edit' ?>addressbook_dialog" title="<?php echo $_['new'] ? $l->t("New Addressbook") : $l->t("Edit Addressbook"); ?>" colspan="6"> <table width="100%" style="border: 0;"> <tr> <th><?php echo $l->t('Displayname') ?></th> diff --git a/apps/contacts/templates/settings.php b/apps/contacts/templates/settings.php index d9130625200..c647e44c25b 100644 --- a/apps/contacts/templates/settings.php +++ b/apps/contacts/templates/settings.php @@ -1,7 +1,7 @@ <form id="mediaform"> <fieldset class="personalblock"> - <strong>Contacts</strong><br /> - CardDAV syncing address: + <strong><?php echo $l->t('Contacts'); ?></strong><br /> + <?php echo $l->t('CardDAV syncing address:'); ?> <?php echo OC_Helper::linkTo('apps/contacts', 'carddav.php', null, true); ?><br /> </fieldset> </form> |