Localizin strings and adding error checking.
This commit is contained in:
parent
eae3e134ff
commit
237ba65a20
|
@ -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),
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 )));
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -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>
|
||||
</form>
|
||||
|
|
|
@ -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>";
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue