Пример #1
0
 function testEditBookmark()
 {
     $this->cleanDB();
     $id = Bookmarks::addBookmark($this->userid, $this->db, "http://www.heise.de", "Heise", array("one", "two"), "PrivatTag", false);
     Bookmarks::editBookmark($this->userid, $this->db, $id, "http://www.google.de", "NewTitle", array("three"));
     $bookmark = Bookmarks::findUniqueBookmark($id, $this->userid, $this->db);
     $this->assertEquals("NewTitle", $bookmark['title']);
     $this->assertEquals("http://www.google.de", $bookmark['url']);
     $this->assertEquals(1, count($bookmark['tags']));
 }
Пример #2
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function bookmarklet($url = "", $title = "")
 {
     $bookmarkExists = Bookmarks::bookmarkExists($url, $this->userId, $this->db);
     $description = "";
     if ($bookmarkExists != false) {
         $bookmark = Bookmarks::findUniqueBookmark($bookmarkExists, $this->userId, $this->db);
         $description = $bookmark['description'];
     }
     $params = array('url' => $url, 'title' => $title, 'description' => $description, 'bookmarkExists' => $bookmarkExists);
     return new TemplateResponse('bookmarks', 'addBookmarklet', $params);
     // templates/main.php
 }
 /**
  @NoAdminRequired
 * 
 * @param int $id
 * @param bool $is_public Description
 * @return \OCP\AppFramework\Http\TemplateResponse
 */
 public function editBookmark($id = null, $url = "", $item = array(), $title = "", $is_public = false, $record_id = null, $description = "")
 {
     // Check if it is a valid URL
     if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
         return new JSONResponse(array(), Http::STATUS_BAD_REQUEST);
     }
     if ($record_id == null) {
         return new JSONResponse(array(), Http::STATUS_BAD_REQUEST);
     }
     $tags = isset($item['tags']) ? $item['tags'] : array();
     if (is_numeric($record_id)) {
         $id = Bookmarks::editBookmark($this->userId, $this->db, $record_id, $url, $title, $tags, $description, $is_public = false);
     }
     $bm = Bookmarks::findUniqueBookmark($id, $this->userId, $this->db);
     return new JSONResponse(array('item' => $bm, 'status' => 'success'));
 }
Пример #4
0
 /**
  @NoAdminRequired
 * 
 * @param int $id
 * @param bool $is_public Description
 * @return \OCP\AppFramework\Http\TemplateResponse
 */
 public function editBookmark($id = null, $url = "", $item = array(), $title = "", $is_public = false, $record_id = null, $description = "")
 {
     // Check if it is a valid URL
     $urlData = parse_url($url);
     if ($urlData === false || !isset($urlData['scheme']) || !isset($urlData['host'])) {
         return new JSONResponse(array(), Http::STATUS_BAD_REQUEST);
     }
     if ($record_id == null) {
         return new JSONResponse(array(), Http::STATUS_BAD_REQUEST);
     }
     $tags = isset($item['tags']) ? $item['tags'] : array();
     if (is_numeric($record_id)) {
         $id = Bookmarks::editBookmark($this->userId, $this->db, $record_id, $url, $title, $tags, $description, $is_public = false);
     }
     $bm = Bookmarks::findUniqueBookmark($id, $this->userId, $this->db);
     return new JSONResponse(array('item' => $bm, 'status' => 'success'));
 }
Пример #5
0
 /**
  * @CORS
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function returnUpdateAsJson($id, $url = "", $tags = array(), $title = "", $description = "")
 {
     $user = \OCP\User::getUser();
     if ($tags[0] == "") {
         $tags = array();
     }
     $output = Bookmarks::editBookmark($user, $this->db, $id, $url, $title, $tags, $description, false);
     if (count($output) == 0) {
         $output["status"] = 'error';
         $output["message"] = "No results from this query";
         return new JSONResponse($output);
     }
     $output = Bookmarks::findUniqueBookmark($output, $user, $this->db);
     return new JSONResponse($output);
 }