Exemplo n.º 1
0
 function testFindTags()
 {
     // 		$uid=uniqid();
     $this->assertEquals(OC_Bookmarks_Bookmarks::findTags(), array());
     OC_Bookmarks_Bookmarks::addBookmark('http://owncloud.org', 'Owncloud project', array('oc', 'cloud'), 'An Awesome project');
     $this->assertEquals(array(0 => array('tag' => 'cloud', 'nbr' => 1), 1 => array('tag' => 'oc', 'nbr' => 1)), OC_Bookmarks_Bookmarks::findTags());
 }
Exemplo n.º 2
0
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
OCP\JSON::checkAppEnabled('bookmarks');
// Check if it is a valid URL
if (filter_var($_POST['url'], FILTER_VALIDATE_URL) === FALSE) {
    OC_JSON::error();
    exit;
}
// If we go the dialog form submit
if (isset($_POST['url'])) {
    $title = isset($_POST['title']) ? $_POST['title'] : '';
    $tags = isset($_POST['item']['tags']) ? $_POST['item']['tags'] : array();
    $pub = isset($_POST['is_public']) ? true : false;
    if (isset($_POST['record_id']) && is_numeric($_POST['record_id'])) {
        //EDIT
        $id = OC_Bookmarks_Bookmarks::editBookmark($_POST['record_id'], $_POST['url'], $_POST['title'], $tags, $_POST['description'], $pub);
    } else {
        if (isset($_POST['from_own'])) {
            $datas = OC_Bookmarks_Bookmarks::getURLMetadata($_POST['url']);
            if (isset($datas['title'])) {
                $title = $datas['title'];
            }
        }
        $id = OC_Bookmarks_Bookmarks::addBookmark($_POST['url'], $title, $tags, $_POST['description'], $pub);
    }
    $bm = OC_Bookmarks_Bookmarks::findOneBookmark($id);
    OCP\JSON::success(array('item' => $bm));
    exit;
}
OC_JSON::error();
exit;