mirror of
https://github.com/owncloud/bookmarks.git
synced 2025-02-07 06:54:15 +01:00
Add description column for bookmarks and correct adding public link
This commit is contained in:
parent
150f2a3f27
commit
bd759557ce
@ -39,7 +39,8 @@ if(!isset($_GET['url']) || trim($_GET['url']) == '') {
|
|||||||
exit;
|
exit;
|
||||||
}elseif(isset($_POST['url'])) {
|
}elseif(isset($_POST['url'])) {
|
||||||
$tags = isset($_POST['item']['tags']) ? $_POST['item']['tags'] : array();
|
$tags = isset($_POST['item']['tags']) ? $_POST['item']['tags'] : array();
|
||||||
$bm = addBookmark($_POST['url'], $_POST['title'], implode(' ',$tags),$_POST['desc'], $_POST['is_public']);
|
$pub = isset($_POST['is_public']) ? true : false;
|
||||||
|
$bm = addBookmark($_POST['url'], $_POST['title'], implode(' ',$tags),$_POST['desc'], $pub);
|
||||||
OCP\JSON::success(array('id'=>$bm));
|
OCP\JSON::success(array('id'=>$bm));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
@ -61,7 +62,7 @@ $bm = array('title'=> $title,
|
|||||||
'url'=> $_GET['url'],
|
'url'=> $_GET['url'],
|
||||||
'tags'=> array(),
|
'tags'=> array(),
|
||||||
'desc'=>'',
|
'desc'=>'',
|
||||||
'is_public'=>1,
|
'is_public'=>0,
|
||||||
);
|
);
|
||||||
|
|
||||||
//Find All Tags
|
//Find All Tags
|
||||||
|
@ -36,6 +36,13 @@
|
|||||||
<notnull>true</notnull>
|
<notnull>true</notnull>
|
||||||
<length>64</length>
|
<length>64</length>
|
||||||
</field>
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>description</name>
|
||||||
|
<type>text</type>
|
||||||
|
<default></default>
|
||||||
|
<notnull>true</notnull>
|
||||||
|
<length>4096</length>
|
||||||
|
</field>
|
||||||
<field>
|
<field>
|
||||||
<name>public</name>
|
<name>public</name>
|
||||||
<type>integer</type>
|
<type>integer</type>
|
||||||
|
@ -1 +1 @@
|
|||||||
0.2
|
0.3
|
@ -70,7 +70,7 @@ function getURLMetadata($url) {
|
|||||||
return $metadata;
|
return $metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addBookmark($url, $title, $tags='') {
|
function addBookmark($url, $title, $tags='', $description='', $is_public=false) {
|
||||||
$CONFIG_DBTYPE = OCP\Config::getSystemValue( "dbtype", "sqlite" );
|
$CONFIG_DBTYPE = OCP\Config::getSystemValue( "dbtype", "sqlite" );
|
||||||
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
|
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
|
||||||
$_ut = "strftime('%s','now')";
|
$_ut = "strftime('%s','now')";
|
||||||
@ -80,28 +80,20 @@ function addBookmark($url, $title, $tags='') {
|
|||||||
$_ut = "UNIX_TIMESTAMP()";
|
$_ut = "UNIX_TIMESTAMP()";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$is_public = $is_public ? 1 : 0;
|
||||||
//FIXME: Detect when user adds a known URL
|
//FIXME: Detect when user adds a known URL
|
||||||
$query = OCP\DB::prepare("
|
$query = OCP\DB::prepare("
|
||||||
INSERT INTO `*PREFIX*bookmarks`
|
INSERT INTO `*PREFIX*bookmarks`
|
||||||
(`url`, `title`, `user_id`, `public`, `added`, `lastmodified`)
|
(url, title, user_id, public, added, lastmodified, description)
|
||||||
VALUES (?, ?, ?, 0, $_ut, $_ut)
|
VALUES (?, ?, ?, ?, $_ut, $_ut, ?)
|
||||||
");
|
");
|
||||||
|
|
||||||
if(empty($title)) {
|
|
||||||
$metadata = getURLMetadata($url);
|
|
||||||
if(isset($metadata['title'])) // Check for problems fetching the title
|
|
||||||
$title = $metadata['title'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(empty($title)) {
|
|
||||||
$l = OC_L10N::get('bookmarks');
|
|
||||||
$title = $l->t('unnamed');
|
|
||||||
}
|
|
||||||
|
|
||||||
$params=array(
|
$params=array(
|
||||||
htmlspecialchars_decode($url),
|
htmlspecialchars_decode($url),
|
||||||
htmlspecialchars_decode($title),
|
htmlspecialchars_decode($title),
|
||||||
OCP\USER::getUser()
|
OCP\USER::getUser(),
|
||||||
|
$is_public,
|
||||||
|
$description,
|
||||||
);
|
);
|
||||||
$query->execute($params);
|
$query->execute($params);
|
||||||
|
|
||||||
|
41
bookmarksHelper.php.rej
Normal file
41
bookmarksHelper.php.rej
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
diff a/bookmarks/bookmarksHelper.php b/bookmarks/bookmarksHelper.php (rejected hunks)
|
||||||
|
@@ -79,29 +79,21 @@ function addBookmark($url, $title, $tags='') {
|
||||||
|
} else {
|
||||||
|
$_ut = "UNIX_TIMESTAMP()";
|
||||||
|
}
|
||||||
|
-
|
||||||
|
+
|
||||||
|
+ $is_public = $is_public ? 1 : 0;
|
||||||
|
//FIXME: Detect when user adds a known URL
|
||||||
|
$query = OCP\DB::prepare("
|
||||||
|
INSERT INTO *PREFIX*bookmarks
|
||||||
|
- (url, title, user_id, public, added, lastmodified)
|
||||||
|
- VALUES (?, ?, ?, 0, $_ut, $_ut)
|
||||||
|
+ (url, title, user_id, public, added, lastmodified, description)
|
||||||
|
+ VALUES (?, ?, ?, ?, $_ut, $_ut, ?)
|
||||||
|
");
|
||||||
|
-
|
||||||
|
- if(empty($title)) {
|
||||||
|
- $metadata = getURLMetadata($url);
|
||||||
|
- if(isset($metadata['title'])) // Check for problems fetching the title
|
||||||
|
- $title = $metadata['title'];
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if(empty($title)) {
|
||||||
|
- $l = OC_L10N::get('bookmarks');
|
||||||
|
- $title = $l->t('unnamed');
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
+
|
||||||
|
$params=array(
|
||||||
|
- htmlspecialchars_decode($url),
|
||||||
|
- htmlspecialchars_decode($title),
|
||||||
|
- OCP\USER::getUser()
|
||||||
|
+ htmlspecialchars_decode($url),
|
||||||
|
+ htmlspecialchars_decode($title),
|
||||||
|
+ OCP\USER::getUser(),
|
||||||
|
+ $is_public,
|
||||||
|
+ $description,
|
||||||
|
);
|
||||||
|
$query->execute($params);
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user