mirror of
https://github.com/chylex/Nextcloud-News.git
synced 2025-04-09 19:15:42 +02:00
remove db methods from Folder class
This commit is contained in:
parent
6e91029b21
commit
c3fac66ea4
@ -26,7 +26,8 @@
|
||||
class OC_News_Folder {
|
||||
|
||||
private $name;
|
||||
private $feed_id;
|
||||
private $id;
|
||||
private $feeds;
|
||||
|
||||
public function __construct($name){
|
||||
$this->name = $name;
|
||||
@ -40,48 +41,4 @@ class OC_News_Folder {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Save the folder into the database
|
||||
* @returns The id of the feed in the database table.
|
||||
*/
|
||||
public function saveToDB() {
|
||||
$CONFIG_DBTYPE = OCP\Config::getSystemValue( "dbtype", "sqlite" );
|
||||
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
|
||||
$_ut = "strftime('%s','now')";
|
||||
} elseif($CONFIG_DBTYPE == 'pgsql') {
|
||||
$_ut = 'date_part(\'epoch\',now())::integer';
|
||||
} else {
|
||||
$_ut = "UNIX_TIMESTAMP()";
|
||||
}
|
||||
|
||||
//FIXME: Detect when user adds a known feed
|
||||
//FIXME: specify folder where you want to add
|
||||
$query = OCP\DB::prepare("
|
||||
INSERT INTO *PREFIX*news_feeds
|
||||
(url, title, added, lastmodified)
|
||||
VALUES (?, ?, $_ut, $_ut)
|
||||
");
|
||||
|
||||
$title = $this->get_title();
|
||||
|
||||
if(empty($title)) {
|
||||
$l = OC_L10N::get('news');
|
||||
$title = $l->t('no title');
|
||||
}
|
||||
|
||||
$params=array(
|
||||
htmlspecialchars_decode($this->url),
|
||||
htmlspecialchars_decode($title)
|
||||
|
||||
//FIXME: user_id is going to move to the folder properties
|
||||
//OCP\USER::getUser()
|
||||
);
|
||||
$query->execute($params);
|
||||
|
||||
$feed_id = OCP\DB::insertid('*PREFIX*news_feeds');
|
||||
|
||||
return $feed_id;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user