function importFolder($name, $parentid) { $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); $l = OC_L10N::get('news'); if (!$folderid) { OCP\Util::writeLog('news', 'ajax/importopml.php: Error adding folder' . $name, OCP\Util::ERROR); return null; } return $folderid; }
* * @author Bernhard Posselt * Copyright (c) 2012 - Bernhard Posselt <*****@*****.**> * * 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();
* @author Alessandro Cosentino * Copyright (c) 2012 - Alessandro Cosentino <*****@*****.**> * * 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();
* */ // Check if we are a user OCP\User::checkLoggedIn(); OCP\App::checkAppEnabled('news'); OCP\App::setActiveNavigationEntry('news'); OCP\Util::addScript('news', 'main'); OCP\Util::addScript('news', 'news'); OCP\Util::addScript('news', 'menu'); OCP\Util::addScript('news', 'items'); OCP\Util::addScript('news', 'jquery.timeago'); OCP\Util::addStyle('news', 'news'); OCP\Util::addStyle('news', 'settings'); $l = OC_L10N::get('news'); $userid = OCP\USER::getUser(); $foldermapper = new OCA\News\FolderMapper($userid); $allfeeds = $foldermapper->childrenOfWithFeeds(0); //$foldermapper->populate($folder); $folderforest = $foldermapper->childrenOf(0); //retrieve all the folders $feedid = 0; $feedtype = 0; if ($allfeeds) { $feedid = isset($_GET['feedid']) ? $_GET['feedid'] : null; if ($feedid == null) { $feedmapper = new OCA\News\FeedMapper(OCP\USER::getUser($userid)); $lastViewedId = OCP\Config::getUserValue($userid, 'news', 'lastViewedFeed'); $lastViewedType = OCP\Config::getUserValue($userid, 'news', 'lastViewedFeedType'); if ($lastViewedId == null || $lastViewedType == null) { $feedid = $feedmapper->mostRecent(); } else {
* * @author Bernhard Posselt * Copyright (c) 2012 - Bernhard Posselt <*****@*****.**> * * 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();
$outline_el->setAttribute('text', $collection->getName()); feedsToXML($collection->getChildren(), $outline_el, $dom); } elseif ($collection instanceof OCA\News\Feed) { $outline_el->setAttribute('title', $collection->getTitle()); $outline_el->setAttribute('text', $collection->getTitle()); $outline_el->setAttribute('type', 'rss'); $outline_el->setAttribute('xmlUrl', $collection->getUrl()); } $xml_el->appendChild($outline_el); } } $l = OC_L10N::get('news'); OCP\User::checkLoggedIn(); OCP\App::checkAppEnabled('news'); $userid = OCP\USER::getUser(); $foldermapper = new OCA\News\FolderMapper($userid); $allfeeds = $foldermapper->childrenOfWithFeeds(0); header('Content-Type: application/x.opml+xml'); $filename = 'ownCloud ' . $l->t('News') . ' ' . $userid; header('Content-Disposition: inline; filename="' . $filename . '.opml"'); $dom = new DomDocument('1.0', 'UTF-8'); $dom->formatOutput = true; $opml_el = $dom->createElement('opml'); $opml_el->setAttribute('version', '2.0'); $head_el = $dom->createElement('head'); $title_el = $dom->createElement('title', $userid . ' ' . $l->t('subscriptions in ownCloud - News')); $head_el->appendChild($title_el); $opml_el->appendChild($head_el); $body_el = $dom->createElement('body'); feedsToXML($allfeeds, $body_el, $dom); $opml_el->appendChild($body_el);
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; }
<?php /** * ownCloud - News app * * @author Alessandro Cosentino * Copyright (c) 2012 - Alessandro Cosentino <*****@*****.**> * * 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)));