Esempio n. 1
0
 /**
  * createBookmark
  * Creates or updates a bookmark.
  * Takes the file id and position with optional comment in parameters.
  * Not supported.
  */
 public static function createbookmark($input)
 {
     self::check_version($input, "1.9.0");
     $id = self::check_parameter($input, 'id');
     $position = self::check_parameter($input, 'position');
     $comment = $input['comment'];
     $type = Subsonic_XML_Data::getAmpacheType($id);
     if (!empty($type)) {
         $bookmark = new Bookmark(Subsonic_XML_Data::getAmpacheId($id), $type);
         if ($bookmark->id) {
             $bookmark->update($position);
         } else {
             Bookmark::create(array('object_id' => Subsonic_XML_Data::getAmpacheId($id), 'object_type' => $type, 'comment' => $comment, 'position' => $position));
         }
         $r = Subsonic_XML_Data::createSuccessResponse();
     } else {
         $r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_DATA_NOTFOUND);
     }
     self::apiOutput($input, $r);
 }
Esempio n. 2
0
<?php

namespace cd;

$session->requireLoggedIn();
switch ($this->owner) {
    case 'adduser':
        // child = user id
        Bookmark::create(BOOKMARK_FAVORITEUSER, $this->child);
        js_redirect('u/bookmark/listusers');
        break;
    case 'removeuser':
        // child = user id
        Bookmark::remove(BOOKMARK_FAVORITEUSER, $this->child);
        js_redirect('u/bookmark/listusers');
        break;
    case 'listusers':
        echo '<h1>Favorite users</h1>';
        $bookmarks = Bookmark::getList(BOOKMARK_FAVORITEUSER, $session->id);
        foreach ($bookmarks as $bm) {
            $u = User::get($bm->value);
            echo ahref('u/profile/' . $u->id, $u->name);
            echo ' ';
            echo ahref('u/bookmark/removeuser/' . $u->id, 'Remove');
            echo '<br/>';
        }
        break;
    default:
        echo 'No handler for view ' . $this->owner;
}
Esempio n. 3
0
 $bookmark->target = $target;
 $bookmark->position = $position;
 if (!$title) {
     $error++;
     setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("BookmarkTitle")), null, 'errors');
 }
 if (!$url) {
     $error++;
     setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("UrlOrLink")), null, 'errors');
 }
 if (!$error) {
     $bookmark->favicon = 'none';
     if ($action == 'update') {
         $res = $bookmark->update();
     } else {
         $res = $bookmark->create();
     }
     if ($res > 0) {
         if (empty($backtopage)) {
             $backtopage = GETPOST("urlsource") ? GETPOST("urlsource") : DOL_URL_ROOT . '/bookmarks/list.php';
         }
         header("Location: " . $backtopage);
         exit;
     } else {
         if ($bookmark->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
             $langs->load("errors");
             setEventMessages($langs->transnoentities("WarningBookmarkAlreadyExists"), null, 'warnings');
         } else {
             setEventMessages($bookmark->error, $bookmark->errors, 'errors');
         }
         $action = $invertedaction;
Esempio n. 4
0
<?php

namespace cd;

$session->requireLoggedIn();
switch ($this->owner) {
    case 'user':
        // child = user id
        if (!$this->child || $this->child == $session->id) {
            die('meh');
        }
        if (confirmed('You sure you want to block this user from contacting you?')) {
            Bookmark::create(BOOKMARK_USERBLOCK, $this->child);
            js_redirect('u/profile/' . $this->child);
        }
        break;
    case 'remove':
        // child = user id
        Bookmark::remove(BOOKMARK_USERBLOCK, $this->child);
        js_redirect('u/block/manage');
        break;
    case 'manage':
        echo '<h1>Manage your blocked users</h1>';
        $list = Bookmark::getList(BOOKMARK_USERBLOCK, $session->id);
        foreach ($list as $o) {
            echo ahref('u/profile/' . $o->value, User::get($o->value)->name) . ' ';
            echo ahref('u/block/remove/' . $o->value, 'Remove block') . '<br/>';
        }
        break;
    default:
        echo 'no such view: ' . $this->owner;