diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-01-27 04:15:53 +0100 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-01-27 04:15:53 +0100 |
commit | ae7393db3d99a7ac223ae917129cccd9f49888e3 (patch) | |
tree | 7f54b72b0d01c38afd1378365a67e4f192922423 /ajax | |
parent | 483784caa38bd6131405ac474347a215584e30a5 (diff) |
merged the angularjs branch
Diffstat (limited to 'ajax')
-rw-r--r-- | ajax/changefoldername.php | 35 | ||||
-rw-r--r-- | ajax/collapsefolder.php | 41 | ||||
-rw-r--r-- | ajax/createfeed.php | 73 | ||||
-rw-r--r-- | ajax/createfolder.php | 47 | ||||
-rw-r--r-- | ajax/deletefeed.php | 37 | ||||
-rw-r--r-- | ajax/deletefolder.php | 33 | ||||
-rw-r--r-- | ajax/feedlist.php | 33 | ||||
-rw-r--r-- | ajax/importdialog.php | 4 | ||||
-rw-r--r-- | ajax/importopml.php | 164 | ||||
-rw-r--r-- | ajax/loadfeed.php | 54 | ||||
-rw-r--r-- | ajax/movefeedtofolder.php | 42 | ||||
-rw-r--r-- | ajax/selectfromcloud.php | 45 | ||||
-rw-r--r-- | ajax/setallitemsread.php | 69 | ||||
-rw-r--r-- | ajax/setitemstatus.php | 53 | ||||
-rw-r--r-- | ajax/updatefeed.php | 47 | ||||
-rw-r--r-- | ajax/uploadopml.php | 42 | ||||
-rw-r--r-- | ajax/usersettings.php | 28 |
17 files changed, 0 insertions, 847 deletions
diff --git a/ajax/changefoldername.php b/ajax/changefoldername.php deleted file mode 100644 index 9c829bccb..000000000 --- a/ajax/changefoldername.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php -/** -* ownCloud - News app -* -* @author Bernhard Posselt -* Copyright (c) 2012 - Bernhard Posselt <nukeawhale@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(); -session_write_close(); - -$folderId = (int)$_POST['folderId']; -$folderName = $_POST['folderName']; - -$folderMapper = new OCA\News\FolderMapper(); -$folder = $folderMapper->find($folderId); -$folder->setName($folderName); -$success = $folderMapper->update($folder); - -$l = OC_L10N::get('news'); - -if(!$success) { - OCP\JSON::error(array('data' => array('message' => $l->t('Error changing name of folder ' . $folderId . ' to ' . $folderName)))); - OCP\Util::writeLog('news','ajax/setallitemsread.php: Error changing name of folder ' . $folderId . ' to ' . $folderName, OCP\Util::ERROR); - exit(); -} - -OCP\JSON::success();
\ No newline at end of file diff --git a/ajax/collapsefolder.php b/ajax/collapsefolder.php deleted file mode 100644 index 5c170a8e6..000000000 --- a/ajax/collapsefolder.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php -/** -* ownCloud - News app -* -* @author Bernhard Posselt -* Copyright (c) 2012 - Bernhard Posselt <nukeawhale@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(); -session_write_close(); - -$folderId = (int)$_POST['folderId']; -if($_POST['opened'] === 'false'){ - $opened = false; -} else { - $opened = true; -} - - -$folderMapper = new OCA\News\FolderMapper(); -$folder = $folderMapper->find($folderId); -$folder->setOpened($opened); -echo $folder->getOpened(); -$success = $folderMapper->update($folder); - -$l = OC_L10N::get('news'); - -if(!$success) { - OCP\JSON::error(array('data' => array('message' => $l->t('Error collapsing folder.')))); - OCP\Util::writeLog('news','ajax/setallitemsread.php: Error collapsing folder with id '. $folderId, OCP\Util::ERROR); - exit(); -} - -OCP\JSON::success();
\ No newline at end of file diff --git a/ajax/createfeed.php b/ajax/createfeed.php deleted file mode 100644 index 52b08a1fd..000000000 --- a/ajax/createfeed.php +++ /dev/null @@ -1,73 +0,0 @@ -<?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 -* -*/ - -register_shutdown_function("shutdown"); - -/* handle the case of fatal error */ -function shutdown() { - $l = OC_L10N::get('news'); - $error = error_get_last(); - if($error['type'] & (E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR)) { //all fatal errors - if (strpos($error['message'], 'get_uri')) { - //handle a fatal error caused by a SimplePie bug (https://github.com/simplepie/simplepie/issues/214) - OCP\Util::writeLog('news','ajax/createfeed.php: Fatal error:' . $error['message'] , OCP\Util::ERROR); - exit(); - } - } -} - -// Check if we are a user -OCP\JSON::checkLoggedIn(); -OCP\JSON::checkAppEnabled('news'); -OCP\JSON::callCheck(); -session_write_close(); - -$userid = OCP\USER::getUser(); - -$feedurl = trim($_POST['feedurl']); -$folderid = trim($_POST['folderid']); - -$feedmapper = new OCA\News\FeedMapper($userid); -$feedid = $feedmapper->findIdFromUrl($feedurl); - - -$l = OC_L10N::get('news'); - -if ($feedid === null) { - $feed = OCA\News\Utils::fetch($feedurl); - - if ($feed !== null) { - $feedid = $feedmapper->save($feed, $folderid); - } -} else { - OCP\JSON::error(array('data' => array('message' => $l->t('Feed already exists.')))); - OCP\Util::writeLog('news','ajax/createfeed.php: Error adding feed: '.$_POST['feedurl'], OCP\Util::ERROR); - exit(); -} - -if($feed === null || !$feedid) { - OCP\JSON::error(array('data' => array('message' => $l->t('Error adding feed.')))); - OCP\Util::writeLog('news','ajax/createfeed.php: Error adding feed: '.$_POST['feedurl'], OCP\Util::ERROR); - exit(); -} - -$itemmapper = new OCA\News\ItemMapper($userid); -$unreadItemsCount = $itemmapper->countAllStatus($feedid, OCA\News\StatusFlag::UNREAD); - -$tmpl_listfeed = new OCP\Template("news", "part.listfeed"); -$tmpl_listfeed->assign('feed', $feed); -$tmpl_listfeed->assign('unreadItemsCount', $unreadItemsCount); -$listfeed = $tmpl_listfeed->fetchPage(); - -OCP\JSON::success(array('data' => array( 'message' => $l->t('Feed added!'), - 'feedid' => $feedid, - 'listfeed' => $listfeed))); diff --git a/ajax/createfolder.php b/ajax/createfolder.php deleted file mode 100644 index 46fc121ff..000000000 --- a/ajax/createfolder.php +++ /dev/null @@ -1,47 +0,0 @@ -<?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(); -session_write_close(); - -$userid = OCP\USER::getUser(); - -$name = trim($_POST['name']); -$parentid = trim($_POST['parentid']); - -$foldermapper = new OCA\News\FolderMapper($userid); - -if($parentid != 0) { - $folder = new OCA\News\Folder($name, null, $foldermapper->find($parentid)); -} else { - $folder = new OCA\News\Folder($name); -} - -$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(); -} - -$tmpl = new OCP\Template("news" , "part.listfolder"); -$tmpl->assign("folder", $folder); -$listfolder = $tmpl->fetchPage(); - -//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('Folder added!'), 'listfolder' => $listfolder))); diff --git a/ajax/deletefeed.php b/ajax/deletefeed.php deleted file mode 100644 index c45931d42..000000000 --- a/ajax/deletefeed.php +++ /dev/null @@ -1,37 +0,0 @@ -<?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(); -session_write_close(); - -$userid = OCP\USER::getUser(); - -$feedid = $_POST['feedid']; - -$feedmapper = new OCA\News\FeedMapper($userid); -$success = $feedmapper->deleteById($feedid); - -$l = OC_L10N::get('news'); - -if(!$success) { - OCP\JSON::error(array('data' => array('message' => $l->t('Error removing feed.')))); - OCP\Util::writeLog('news','ajax/deletefeed.php: Error removing feed: '.$_POST['feedid'], OCP\Util::ERROR); - exit(); -} - -$tmpl = new OCP\Template("news", "part.items.deleted"); -$part_items = $tmpl->fetchPage(); - -OCP\JSON::success(array('data' => array( 'feedid' => $feedid, 'part_items' => $part_items ))); diff --git a/ajax/deletefolder.php b/ajax/deletefolder.php deleted file mode 100644 index ddde1c992..000000000 --- a/ajax/deletefolder.php +++ /dev/null @@ -1,33 +0,0 @@ -<?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(); -session_write_close(); - -$userid = OCP\USER::getUser(); - -$folderid = trim($_POST['folderid']); -$part_items = false; - -$foldermapper = new OCA\News\FolderMapper($userid); - -if(!$foldermapper->deleteById($folderid)) { - OCP\JSON::error(array('data' => array('message' => $l->t('Error removing folder.')))); - OCP\Util::writeLog('news','ajax/deletefolder.php: Error removing folder: '.$_POST['folderid'], OCP\Util::ERROR); - exit(); -} - - -OCP\JSON::success(array('data' => array( 'folderid' => $folderid ))); diff --git a/ajax/feedlist.php b/ajax/feedlist.php deleted file mode 100644 index 3b79807f3..000000000 --- a/ajax/feedlist.php +++ /dev/null @@ -1,33 +0,0 @@ -<?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(); -session_write_close(); - -$userid = OCP\USER::getUser(); - -$feedmapper = new OCA\News\FeedMapper($userid); -$feeds = $feedmapper->findAll(); - -$l = OC_L10N::get('news'); - -if($feeds == null) { - //TODO: handle error better here - OCP\JSON::error(array('data' => array('message' => $l->t('Error updating feeds.')))); - OCP\Util::writeLog('news','ajax/feedlist.php: Error updating feeds', OCP\Util::ERROR); - exit(); -} - -OCP\JSON::success(array('data' => $feeds)); diff --git a/ajax/importdialog.php b/ajax/importdialog.php deleted file mode 100644 index c91b5dead..000000000 --- a/ajax/importdialog.php +++ /dev/null @@ -1,4 +0,0 @@ -<?php - -$output = new OCP\Template("news", "part.importdialog"); -$output->printpage();
\ No newline at end of file diff --git a/ajax/importopml.php b/ajax/importopml.php deleted file mode 100644 index 3733f5413..000000000 --- a/ajax/importopml.php +++ /dev/null @@ -1,164 +0,0 @@ -<?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(); - -global $l; -$l = OC_L10N::get('news'); - -function bailOut($msg) { - global $eventSource; - $eventSource->send('error', $msg); - $eventSource->close(); - OCP\Util::writeLog('news','ajax/importopml.php: '.$msg, OCP\Util::ERROR); - exit(); -} - -global $eventSource; -$eventSource=new OC_EventSource(); - -require_once 'news/opmlparser.php'; - -$source = isset( $_REQUEST['source'] ) ? $_REQUEST['source'] : ''; -$path = isset( $_REQUEST['path'] ) ? $_REQUEST['path'] : ''; - -if($path == '') { - bailOut($l->t('Empty filename')); - exit(); -} - -if($source == 'cloud') { - $raw = file_get_contents($path); -} elseif ($source == 'local') { - $storage = \OCP\Files::getStorage('news'); - $raw = $storage->file_get_contents($path); -} else { - bailOut($l->t('No source argument passed')); -} - -if ($raw == false) { - bailOut($l->t('Error while reading file')); -} - -try { - $parsed = OPMLParser::parse($raw); -} catch (Exception $e) { - bailOut($e->getMessage()); -} - -if ($parsed == null) { - bailOut($l->t('An error occurred while parsing the file.')); -} - -$data = $parsed->getData(); - -function importFeed($feedurl, $folderid, $feedtitle) { - - global $eventSource; - global $l; - - $feedmapper = new OCA\News\FeedMapper(); - $feedid = $feedmapper->findIdFromUrl($feedurl); - - if ($feedid === null) { - $feed = OCA\News\Utils::slimFetch($feedurl); - - if ($feed !== null) { - $feed->setTitle($feedtitle); //we want the title of the feed to be the one from the opml file - $feedid = $feedmapper->save($feed, $folderid); - - $itemmapper = new OCA\News\ItemMapper(OCP\USER::getUser()); - $unreadItemsCount = $itemmapper->countAllStatus($feedid, OCA\News\StatusFlag::UNREAD); - - $tmpl_listfeed = new OCP\Template("news", "part.listfeed"); - $tmpl_listfeed->assign('feed', $feed); - $tmpl_listfeed->assign('unreadItemsCount', $unreadItemsCount); - $listfeed = $tmpl_listfeed->fetchPage(); - - $eventSource->send('progress', array('data' => array('type'=>'feed', 'folderid'=>$folderid, 'listfeed'=>$listfeed))); - } - } else { - OCP\Util::writeLog('news','ajax/importopml.php: This feed is already here: '. $feedurl, OCP\Util::WARN); - return true; - } - - if($feed === null || !$feedid) { - OCP\Util::writeLog('news','ajax/importopml.php: Error adding feed: '. $feedurl, OCP\Util::ERROR); - return false; - } - - return true; -} - -function importFolder($name, $parentid) { - - global $eventSource; - global $l; - - $foldermapper = new OCA\News\FolderMapper(); - - if($parentid != 0) { - $folder = new OCA\News\Folder($name, null, $foldermapper->find($parentid)); - } else { - $folder = new OCA\News\Folder($name); - } - - $folderid = $foldermapper->save($folder); - - $tmpl = new OCP\Template("news" , "part.listfolder"); - $tmpl->assign("folder", $folder); - $listfolder = $tmpl->fetchPage(); - - $eventSource->send('progress', array('data' => array('type'=>'folder', 'listfolder'=>$listfolder))); - - if(!$folderid) { - OCP\Util::writeLog('news','ajax/importopml.php: Error adding folder' . $name, OCP\Util::ERROR); - return null; - } - - return $folderid; -} - -function importList($data, $parentid) { - $countsuccess = 0; - foreach($data as $collection) { - if ($collection instanceOf OCA\News\Feed) { - $feedurl = $collection->getUrl(); - $feedtitle = $collection->getTitle(); - if (importFeed($feedurl, $parentid, $feedtitle)) { - $countsuccess++; - } - } - else if ($collection instanceOf OCA\News\Folder) { - $folderid = importFolder($collection->getName(), $parentid); - if ($folderid) { - $children = $collection->getChildren(); - $countsuccess += importList($children, $folderid); - } - } - else { - OCP\Util::writeLog('news','ajax/importopml.php: Error importing OPML',OCP\Util::ERROR); - } - } - return $countsuccess; -} - -$countsuccess = importList($data, 0); - -$eventSource->send('success', array('data' => array('title'=>$parsed->getTitle(), 'count'=>$parsed->getCount(), - 'countsuccess'=>$countsuccess))); -$eventSource->close(); diff --git a/ajax/loadfeed.php b/ajax/loadfeed.php deleted file mode 100644 index 2deca7076..000000000 --- a/ajax/loadfeed.php +++ /dev/null @@ -1,54 +0,0 @@ -<?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(); -session_write_close(); - -require_once OC_App::getAppPath('news') . '/lib/feedtypes.php'; -require_once OC_App::getAppPath('news') . '/controllers/controller.php'; -require_once OC_App::getAppPath('news') . '/controllers/news.controller.php'; - -$userid = OCP\USER::getUser(); - -$feedId = (int)$_POST['id']; -$feedType = (int)$_POST['type']; - - -OCP\Config::setUserValue(OCP\USER::getUser(), 'news', 'lastViewedFeed', $feedId); -OCP\Config::setUserValue(OCP\USER::getUser(), 'news', 'lastViewedFeedType', $feedType); - -$showAll = OCP\Config::getUserValue(OCP\USER::getUser(), 'news', 'showAll'); - -$newsController = new OCA\News\NewsController(); -$items = $newsController->getItems($feedType, $feedId, $showAll); -$unreadItemCount = $newsController->getItemUnreadCount($feedType, $feedId); - -$l = OC_L10N::get('news'); - - -$itemsTpl = new OCP\Template("news", "part.items"); -$itemsTpl->assign('lastViewedFeedId', $feedId); -$itemsTpl->assign('lastViewedFeedType', $feedType); -$itemsTpl->assign('items', $items, false); -$feedItems = $itemsTpl->fetchPage(); - -$itemMapper = new OCA\News\ItemMapper(); - - - - -OCP\JSON::success(array('data' => array( 'message' => $l->t('Feed loaded!'), - 'feedItems' => $feedItems, - 'unreadItemCount' => $unreadItemCount ))); diff --git a/ajax/movefeedtofolder.php b/ajax/movefeedtofolder.php deleted file mode 100644 index 92d618c67..000000000 --- a/ajax/movefeedtofolder.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php -/** -* ownCloud - News app -* -* @author Bernhard Posselt -* Copyright (c) 2012 - Bernhard Posselt <nukeawhale@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(); -session_write_close(); - -$folderId = (int)$_POST['folderId']; -$feedId = $_POST['feedId']; - - -$feedMapper = new OCA\News\FeedMapper(); -$feed = $feedMapper->findById($feedId); - -if($folderId === 0) { - $success = $feedMapper->save($feed, $folderId); -} else { - $folderMapper = new OCA\News\FolderMapper(); - $folder = $folderMapper->find($folderId); - $success = $feedMapper->save($feed, $folder->getId()); -} - -$l = OC_L10N::get('news'); - -if(!$success) { - OCP\JSON::error(array('data' => array('message' => $l->t('Error moving feed into folder.')))); - OCP\Util::writeLog('news','ajax/setallitemsread.php: Error moving feed ' . $feedId . ' into folder '. $folderId, OCP\Util::ERROR); - exit(); -} - -OCP\JSON::success();
\ No newline at end of file diff --git a/ajax/selectfromcloud.php b/ajax/selectfromcloud.php deleted file mode 100644 index eae8f0a81..000000000 --- a/ajax/selectfromcloud.php +++ /dev/null @@ -1,45 +0,0 @@ -<?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(); -session_write_close(); - -$l = OC_L10N::get('news'); - -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('news','ajax/selectfromcloud.php: '.$msg, OCP\Util::ERROR); - exit(); -} -function debug($msg) { - OCP\Util::writeLog('news','ajax/selectfromcloud.php: '.$msg, OCP\Util::DEBUG); -} - -if(!isset($_GET['path'])) { - bailOut($l->t('No file path was submitted.')); -} - -$localpath = OC_Filesystem::getLocalFile($_GET['path']); -$tmpfname = tempnam(get_temp_dir(), "occOrig"); - -if(!file_exists($localpath)) { - bailOut($l->t('File doesn\'t exist:').$localpath); -} - -if (file_put_contents($tmpfname, file_get_contents($localpath))) { - OCP\JSON::success(array('data' => array('tmp'=>$tmpfname, 'path'=>$localpath))); -} else { - bailOut($l->t('Couldn\'t save temporary image: ').$tmpfname); -} diff --git a/ajax/setallitemsread.php b/ajax/setallitemsread.php deleted file mode 100644 index 059c14749..000000000 --- a/ajax/setallitemsread.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php -/** -* ownCloud - News app -* -* @author Bernhard Posselt -* Copyright (c) 2012 - Bernhard Posselt <nukeawhale@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(); -session_write_close(); - -$feedId = $_POST['feedId']; -$mostRecentItemId = (int)$_POST['mostRecentItemId']; - -$itemMapper = new OCA\News\ItemMapper(); - -//echo $mostRecentItem->getDate(); -switch ($feedId) { - case -2: - $items = $itemMapper->findEveryItemByStatus(OCA\News\StatusFlag::UNREAD); - break; - - case -1: - $items = $itemMapper->findEveryItemByStatus(OCA\News\StatusFlag::UNREAD | OCA\News\StatusFlag::IMPORTANT); - break; - - default: - $items = $itemMapper->findAllStatus($feedId, OCA\News\StatusFlag::UNREAD); - break; -} - - -// FIXME: maybe there is a way to set all items read in the -// FeedMapper instead of iterating through every item and updating as -// necessary -$success = false; -if($mostRecentItemId !== 0) { - $mostRecentItem = $itemMapper->findById($mostRecentItemId); -} - -$unreadCount = count($items); -foreach($items as $item) { - // FIXME: this should compare the modified date - if($mostRecentItemId === 0 || $item->getDate() <= $mostRecentItem->getDate()) { - $item->setRead(); - $success = $itemMapper->update($item); - $unreadCount--; - } -} - -$l = OC_L10N::get('news'); - -// FIXME: when we have no items we to mark read we shouldnt throw an error -$success = true; -if(!$success) { - OCP\JSON::error(array('data' => array('message' => $l->t('Error setting all items as read.')))); - OCP\Util::writeLog('news','ajax/setallitemsread.php: Error setting all items as read of feed '. $feedId, 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('feedId' => $feedId, 'unreadCount' => $unreadCount))); diff --git a/ajax/setitemstatus.php b/ajax/setitemstatus.php deleted file mode 100644 index 1886de738..000000000 --- a/ajax/setitemstatus.php +++ /dev/null @@ -1,53 +0,0 @@ -<?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(); -session_write_close(); - -$itemId = $_POST['itemId']; -$status = $_POST['status']; - -$itemMapper = new OCA\News\ItemMapper(); -$item = $itemMapper->findById($itemId); - -switch ($status) { - case 'read': - $item->setRead(); - break; - case 'unread': - $item->setUnread(); - break; - case 'important': - $item->setImportant(); - break; - case 'unimportant': - $item->setUnimportant(); - break; - default: - break; -} - -$success = $itemMapper->update($item); - -$l = OC_L10N::get('news'); - -if(!$success) { - OCP\JSON::error(array('data' => array('message' => $l->t('Error marking item as read.')))); - OCP\Util::writeLog('news','ajax/setitemstatus.php: Error setting itemstatus to '. $status .': '.$_POST['itemid'], 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('itemId' => $itemId ))); diff --git a/ajax/updatefeed.php b/ajax/updatefeed.php deleted file mode 100644 index 19542fa6d..000000000 --- a/ajax/updatefeed.php +++ /dev/null @@ -1,47 +0,0 @@ -<?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(); -session_write_close(); - -$userid = OCP\USER::getUser(); - -$feedid = $_POST['feedid']; -$feedurl = $_POST['feedurl']; -$folderid = $_POST['folderid']; - -$newfeed = OCA\News\Utils::fetch($feedurl); - -$newfeedid = false; - -if ($newfeed !== null) { - $feedmapper = new OCA\News\FeedMapper(); - $newfeedid = $feedmapper->save($newfeed, $folderid); -} - -$l = OC_L10N::get('news'); - -if(!$newfeedid) { - OCP\JSON::error(array('data' => array('message' => $l->t('Error updating feed.')))); - OCP\Util::writeLog('news','ajax/updatefeed.php: Error updating feed: '.$_POST['feedid'], OCP\Util::ERROR); - exit(); -} -else { - $itemmapper = new OCA\News\ItemMapper($userid); - $unreadcounter = $itemmapper->countAllStatus($newfeedid, OCA\News\StatusFlag::UNREAD); - - OCP\JSON::success(array('data' => array('message' => $l->t('Feed updated!'), 'unreadcount' => $unreadcounter))); - exit(); -} diff --git a/ajax/uploadopml.php b/ajax/uploadopml.php deleted file mode 100644 index d982e0324..000000000 --- a/ajax/uploadopml.php +++ /dev/null @@ -1,42 +0,0 @@ -<?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(); - -$l = OC_L10N::get('news'); - -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('news','ajax/uploadopml.php: '.$msg, OCP\Util::ERROR); - exit(); -} - -if (isset($_POST['path'])) { - OCP\JSON::success(array('data' => array('source'=> 'cloud', 'path' => $_POST['path']))); - -} -elseif (isset($_FILES['file'])) { - $storage = \OCP\Files::getStorage('news'); - $filename = 'opmlfile.xml'; - if ($storage->fromTmpFile($_FILES['file']['tmp_name'], $filename)) { - OCP\JSON::success(array('data' => array('source'=> 'local', 'path' => $filename))); - } else { - bailOut('Could not create the temporary file'); - } - |