From 5754af967cb92c49ae90c544725eb5a9ed33fc59 Mon Sep 17 00:00:00 2001 From: Alessandro Cosentino Date: Sat, 7 Jul 2012 19:03:35 -0400 Subject: [PATCH] starts implementing updateitem --- ajax/markitem.php | 34 ++++++++++++++++++++++++++++++++++ css/news.css | 3 ++- js/news.js | 18 +++++++++++++++++- templates/part.items.php | 9 ++++++++- 4 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 ajax/markitem.php diff --git a/ajax/markitem.php b/ajax/markitem.php new file mode 100644 index 000000000..ea54d79e3 --- /dev/null +++ b/ajax/markitem.php @@ -0,0 +1,34 @@ + +* +* 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(); + +$itemid = trim($_POST['itemid']); + +$itemmapper = new OC_News_ItemMapper(); +$item = $itemmapper->find($itemid); +$feedid = $itemmapper->save($feed, 0); + +$l = OC_L10N::get('news'); + +if(!$feedid) { + OCP\JSON::error(array('data' => array('message' => $l->t('Error adding folder.')))); + OCP\Util::writeLog('news','ajax/newfeed.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!')))); + diff --git a/css/news.css b/css/news.css index 7e7256849..f36304531 100644 --- a/css/news.css +++ b/css/news.css @@ -12,4 +12,5 @@ ul.controls li { float: left; } -.accordion .title { background: #DCDCDC; font-size: 12px; border-bottom:1px solid #ccc; font-weight:bold;} +.accordion .title_unread { background: #DCDCDC; font-size: 12px; border-bottom:1px solid #ccc; font-weight:bold;} +.accordion .title_read { background: #DCDCDC; font-size: 12px; border-bottom:1px solid #ccc;} diff --git a/js/news.js b/js/news.js index b940a3f69..25a6d6f34 100644 --- a/js/news.js +++ b/js/news.js @@ -97,6 +97,16 @@ News={ } }); return false; + }, + markItem:function(itemid) { + $.post(OC.filePath('news', 'ajax', 'markitem.php'),{'itemid':itemid},function(jsondata){ + if(jsondata.status == 'success'){ + + } + else{ + OC.dialogs.alert(jsondata.data.message, t('news', 'Error')); + } + }); } } } @@ -110,10 +120,16 @@ $(document).ready(function(){ $(this).toggle(); }); - $('.accordion .title').click(function() { + $('.accordion .title_unread').click(function() { $(this).next().toggle(); return false; }).next().hide(); + + $('.accordion .title_read').click(function() { + $(this).next().toggle(); + return false; + }).next().hide(); + $('.feeds_list').hover(function() { $(this).find('#feeds_delete').toggle(); diff --git a/templates/part.items.php b/templates/part.items.php index d109d6d34..d1336b838 100644 --- a/templates/part.items.php +++ b/templates/part.items.php @@ -8,7 +8,14 @@ $items = $itemmapper->findAll($feedid); echo '';