diff --git a/addBm.php b/addBm.php
index 9329f46e..bc039c4d 100644
--- a/addBm.php
+++ b/addBm.php
@@ -39,7 +39,8 @@ if(!isset($_GET['url']) || trim($_GET['url']) == '') {
exit;
}elseif(isset($_POST['url'])) {
$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));
exit();
}
@@ -61,7 +62,7 @@ $bm = array('title'=> $title,
'url'=> $_GET['url'],
'tags'=> array(),
'desc'=>'',
- 'is_public'=>1,
+ 'is_public'=>0,
);
//Find All Tags
diff --git a/appinfo/database.xml b/appinfo/database.xml
index d28857b0..6e45d5e1 100644
--- a/appinfo/database.xml
+++ b/appinfo/database.xml
@@ -36,6 +36,13 @@
true
64
+
+ description
+ text
+
+ true
+ 4096
+
public
integer
diff --git a/appinfo/version b/appinfo/version
index 2f453618..1d71ef97 100644
--- a/appinfo/version
+++ b/appinfo/version
@@ -1 +1 @@
-0.2
\ No newline at end of file
+0.3
\ No newline at end of file
diff --git a/bookmarksHelper.php b/bookmarksHelper.php
index 80cce751..e3b8df2a 100644
--- a/bookmarksHelper.php
+++ b/bookmarksHelper.php
@@ -54,7 +54,7 @@ function getURLMetadata($url) {
//if not (allowed) protocol is given, assume http
if(preg_match($protocols, $url) == 0) {
$url = 'http://' . $url;
- }
+ }
$metadata['url'] = $url;
if (!function_exists('curl_init')){
return $metadata;
@@ -66,11 +66,11 @@ function getURLMetadata($url) {
curl_close($ch);
@preg_match( "/(.*)<\/title>/sUi", $page, $match );
- $metadata['title'] = htmlspecialchars_decode(@$match[1]);
+ $metadata['title'] = htmlspecialchars_decode(@$match[1]);
return $metadata;
}
-function addBookmark($url, $title, $tags='') {
+function addBookmark($url, $title, $tags='', $description='', $is_public=false) {
$CONFIG_DBTYPE = OCP\Config::getSystemValue( "dbtype", "sqlite" );
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
$_ut = "strftime('%s','now')";
@@ -79,41 +79,33 @@ 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);
-
+
$b_id = OCP\DB::insertid('*PREFIX*bookmarks');
-
+
if($b_id !== false) {
$query = OCP\DB::prepare("
INSERT INTO `*PREFIX*bookmarks_tags`
(`bookmark_id`, `tag`)
VALUES (?, ?)
");
-
+
$tags = explode(' ', urldecode($tags));
foreach ($tags as $tag) {
if(empty($tag)) {
@@ -123,7 +115,7 @@ function addBookmark($url, $title, $tags='') {
$params = array($b_id, trim($tag));
$query->execute($params);
}
-
+
return $b_id;
}
}
diff --git a/bookmarksHelper.php.rej b/bookmarksHelper.php.rej
new file mode 100644
index 00000000..ba45ecb3
--- /dev/null
+++ b/bookmarksHelper.php.rej
@@ -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);
+