diff options
author | Alessandro Cosentino <cosenal@gmail.com> | 2012-06-29 19:01:41 -0400 |
---|---|---|
committer | Alessandro Cosentino <cosenal@gmail.com> | 2012-06-29 19:01:41 -0400 |
commit | 6f3404ee971a130b90cf1773b9e67f4feef0be74 (patch) | |
tree | 50dc6137a02b73327e7ae9a6ae081a99f0295085 /ajax | |
parent | 6d54ff8c008058f6a90924a88b16f44bca0c0b25 (diff) |
adds controller to add a folder
Diffstat (limited to 'ajax')
-rw-r--r-- | ajax/createfolder.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/ajax/createfolder.php b/ajax/createfolder.php new file mode 100644 index 000000000..ecc44df49 --- /dev/null +++ b/ajax/createfolder.php @@ -0,0 +1,35 @@ +<?php +/** +* ownCloud - News app +* +* @author Alessandro Cosentino +* Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com> +* +* This file is licensed under the Affero General Public License version 3 or later. +* See the COPYING-README file +* +*/ + +// Check if we are a user +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('news'); +OCP\JSON::callCheck(); + +$userid = OCP\USER::getUser(); + +$name = trim($_POST['name']); +$folder = new OC_News_Folder($name); +$foldermapper = new OC_News_FolderMapper($userid); +$folderid = $foldermapper->save($folder); + +$l = OC_L10N::get('news'); + +if(!$folderid) { + OCP\JSON::error(array('data' => array('message' => $l->t('Error adding folder.')))); + OCP\Util::writeLog('news','ajax/createfolder.php: Error adding folder: '.$_POST['name'], OCP\Util::ERROR); + exit(); +} + +//TODO: replace the following with the success case. see contact/ajax/createaddressbook.php for inspirations +OCP\JSON::error(array('data' => array('message' => $l->t('Error adding folder.')))); + |