$group = new EfrontGroup($result[0]); echo json_encode($group->useKeyForUser($currentUser)); } else { throw new Exception(_INVALIDKEY . ': ' . $_GET['group_key']); } } catch (Exception $e) { handleAjaxExceptions($e); } exit; } if (isset($_GET['bookmarks']) && EfrontUser::isOptionVisible('bookmarks')) { try { $bookmarks = bookmarks::getBookmarks($currentUser, $currentLesson); if ($_GET['bookmarks'] == 'remove' && in_array($_GET['id'], array_keys($bookmarks))) { $bookmark = new bookmarks($_GET['id']); $bookmark->delete(); } elseif ($_GET['bookmarks'] == 'add') { foreach ($bookmarks as $value) { $urls[] = $value['url']; } if (!in_array($_SERVER['PHP_SELF'] . "?view_unit=" . $currentUnit['id'], $urls)) { $fields = array('users_LOGIN' => $currentUser->user['login'], 'lessons_ID' => $currentLesson->lesson['id'], 'name' => $currentUnit['name'], 'url' => $_SERVER['PHP_SELF'] . "?view_unit=" . $currentUnit['id']); bookmarks::create($fields); } } else { echo json_encode($bookmarks); } } catch (Exception $e) { handleAjaxExceptions($e); } exit;