コード例 #1
0
<?php

require_once "../phplib/util.php";
$user = session_getUser();
if (!$user) {
    util_redirect('auth/login');
}
SmartyWrap::assign('bookmarks', UserWordBookmarkDisplayObject::getByUser($user->id));
SmartyWrap::display('cuvinte-favorite.tpl');
コード例 #2
0
ファイル: bookmarkAdd.php プロジェクト: florinp/dexonline
<?php

require_once "../../phplib/util.php";
$definitionId = util_getRequestParameter('definitionId');
$response = array();
$userId = session_getUserId();
if (!$userId) {
    $response['status'] = 'redirect';
    $response['url'] = 'login';
    echo json_encode($response);
    exit;
}
$bookmarks = UserWordBookmarkDisplayObject::getByUser($userId);
if (count($bookmarks) < Config::get('global.maxBookmarks')) {
    $existing = Model::factory('UserWordBookmark')->where('userId', $userId)->where('definitionId', $definitionId)->find_one();
    if (!$existing) {
        $bookmark = Model::factory('UserWordBookmark')->create();
        $bookmark->userId = $userId;
        $bookmark->definitionId = $definitionId;
        $bookmark->save();
        log_userLog("Added to favorites: {$bookmark->id} - the definition with the id {$bookmark->definitionId} for user {$bookmark->userId}");
    }
    $response['status'] = 'success';
} else {
    $response['status'] = 'error';
    $response['msg'] = 'Ați depășit limita de cuvinte favorite. Limita este ' . Config::get('global.maxBookmarks') . ' cuvinte favorite.';
}
echo json_encode($response);