add bookmarks api and iimports, bugfixes

This commit is contained in:
Joey Kimsey
2024-12-07 01:55:13 -05:00
parent dcffa0a7fb
commit 755646ba30
10 changed files with 256 additions and 42 deletions

View File

@ -51,14 +51,17 @@ class Bookmarks extends DatabaseModel {
parent::__construct();
}
public function create( $title, $url, $folderID = 0, $description = '', $color = 'default', $privacy = 'private', $type = 'external' ) {
public function create( $title, $url, $folderID = 0, $description = '', $color = 'default', $privacy = 'private', $type = 'external', $user = null ) {
if ( empty( $user ) ) {
$user = App::$activeUser->ID;
}
$fields = [
'title' => $title,
'url' => $url,
'description' => $description,
'color' => $color,
'privacy' => $privacy,
'createdBy' => App::$activeUser->ID,
'createdBy' => $user,
'createdAt' => time(),
];
if ( !empty( $folderID ) ) {
@ -675,9 +678,12 @@ class Bookmarks extends DatabaseModel {
return true;
}
private function getBaseUrl ($url ) {
$parsedUrl = parse_url($url);
private function getBaseUrl ( $url ) {
if ( empty($url) ) {
return $url;
}
$parsedUrl = parse_url($url);
if (isset($parsedUrl['scheme']) && isset($parsedUrl['host'])) {
return $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . '/';
} else {