1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-02-17 11:54:16 +01:00

Delete groups by their id instead of their name.

This commit is contained in:
Bernhard Reiter 2014-09-08 18:32:18 +02:00
parent 83bc1eaadf
commit c86dbf11b5
3 changed files with 9 additions and 8 deletions

View File

@ -475,7 +475,7 @@ OC.Contacts = OC.Contacts || {};
var contacts = $elem.data('contacts');
var self = this;
console.log('delete group', $elem, groupid, contacts);
$.when(this.storage.deleteGroup(name)).then(function(response) {
$.when(this.storage.deleteGroup(groupid, name)).then(function(response) {
if (!response.error) {
$.each(self.categories, function(idx, category) {
if(category.id === groupid) {

View File

@ -578,12 +578,12 @@ OC.Contacts = OC.Contacts || {};
*
* @param string name
*/
Storage.prototype.deleteGroup = function(name) {
Storage.prototype.deleteGroup = function(id, name) {
return this.requestRoute(
'groups/delete',
'POST',
{},
JSON.stringify({name: name})
JSON.stringify({id: id, name: name})
);
};

View File

@ -84,22 +84,24 @@ class GroupController extends Controller {
* @NoAdminRequired
*/
public function deleteGroup() {
$id = $this->request->post['id'];
$name = $this->request->post['name'];
$response = new JSONResponse();
if (is_null($name) || $name === '') {
$response->bailOut(App::$l10n->t('No group name given.'));
if (is_null($id) || $id === '') {
$response->bailOut(App::$l10n->t('No group ID given.'));
return $response;
}
try {
$ids = $this->tags->getIdsForTag($name);
$ids = $this->tags->getIdsForTag($id);
} catch(\Exception $e) {
$response->setErrorMessage($e->getMessage());
\OCP\Util::writeLog('contacts', __METHOD__.', ' . $e->getMessage(), \OCP\Util::ERROR);
return $response;
}
$tagId = $id;
if ($ids !== false) {
$backend = $this->app->getBackend('local');
@ -129,12 +131,11 @@ class GroupController extends Controller {
}
try {
$this->tags->delete($name);
$this->tags->delete($tagId);
} catch(\Exception $e) {
$response->setErrorMessage($e->getMessage());
\OCP\Util::writeLog('contacts', __METHOD__.', ' . $e->getMessage(), \OCP\Util::ERROR);
}
return $response;
}