diff options
author | Alessandro Cosentino <cosenal@gmail.com> | 2012-07-16 18:46:59 -0400 |
---|---|---|
committer | Alessandro Cosentino <cosenal@gmail.com> | 2012-07-16 18:46:59 -0400 |
commit | f54ffd3ed781721f5176b14be346fde55cdaaed6 (patch) | |
tree | dfb58ab6509c554cd256e2c764be376a6dfdf8b0 /ajax/updatefeed.php | |
parent | b87705aa94467e37bafe212ab09c0cd972fe4f60 (diff) |
skeleton of updatefeeds feature
Diffstat (limited to 'ajax/updatefeed.php')
-rw-r--r-- | ajax/updatefeed.php | 37 |
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!')))); + |