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),
// 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 );
}
}
$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);
}
}
-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');
<?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.
$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);
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
+$l10n = new OC_L10N('contacts');
$id = $_GET['id'];
$checksum = $_GET['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 )));
}
// 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');
<?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.
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);
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);
}
});
$('#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);
}
});
$('#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);
}
});
$('#rightcontent').empty();
}
else{
- Contacts.UI.messageBox('Error', jsondata.data.message);
+ Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
//alert(jsondata.data.message);
}
});
$('#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);
}
});
$('#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;
.find('select').chosen();
}
else{
- Contacts.UI.messageBox('Error', jsondata.data.message);
+ Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
//alert(jsondata.data.message);
}
});
}
}
else{
- Contacts.UI.messageBox('Error', jsondata.data.message);
+ Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
//alert(jsondata.data.message);
}
}, 'json');
.find('select').chosen();
}
else{
- Contacts.UI.messageBox('Error', jsondata.data.message);
+ Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
//alert(jsondata.data.message);
}
});
$('.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');
$('.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);
}
});
--- /dev/null
+../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
* @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));
* @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));
* @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));
<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">
<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">
</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>
<?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>";
* 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>
<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>