summaryrefslogtreecommitdiffstats
path: root/ajax/updatefeed.php
diff options
context:
space:
mode:
authorAlessandro Cosentino <cosenal@gmail.com>2012-07-16 18:46:59 -0400
committerAlessandro Cosentino <cosenal@gmail.com>2012-07-16 18:46:59 -0400
commitf54ffd3ed781721f5176b14be346fde55cdaaed6 (patch)
treedfb58ab6509c554cd256e2c764be376a6dfdf8b0 /ajax/updatefeed.php
parentb87705aa94467e37bafe212ab09c0cd972fe4f60 (diff)
skeleton of updatefeeds feature
Diffstat (limited to 'ajax/updatefeed.php')
-rw-r--r--ajax/updatefeed.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/ajax/updatefeed.php b/ajax/updatefeed.php
new file mode 100644
index 000000000..754d87495
--- /dev/null
+++ b/ajax/updatefeed.php
@@ -0,0 +1,37 @@
+<?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();
+
+$feedurl = trim($_POST['feedurl']);
+$folderid = trim($_POST['folderid']);
+
+$feed = OC_News_Utils::fetch($feedurl);
+$feedmapper = new OC_News_FeedMapper();
+$feedid = $feedmapper->save($feed, $folderid);
+
+$l = OC_L10N::get('news');
+
+if(!$feedid) {
+ OCP\JSON::error(array('data' => array('message' => $l->t('Error adding folder.'))));
+ OCP\Util::writeLog('news','ajax/createfeed.php: Error adding feed: '.$_POST['feedurl'], OCP\Util::ERROR);
+ exit();
+}
+
+//TODO: replace the following with a real success case. see contact/ajax/createaddressbook.php for inspirations
+OCP\JSON::success(array('data' => array('message' => $l->t('Feed added!'))));
+