Package com.psddev.cms.db

Examples of com.psddev.cms.db.ToolUser


        return null;
    }

    @Override
    protected void doService(ToolPageContext page) throws IOException, ServletException {
        ToolUser user = page.getUser();
        Collection<String> includeFields = Arrays.asList("returnToDashboardOnSave");
        Object object = Query.from(Object.class).where("_id = ?", page.param(UUID.class, "id")).first();
        State state = State.getInstance(object);
        ContentLock contentLock = null;

        if (object != null) {
            contentLock = ContentLock.Static.lock(object, null, user);
        }

        if (page.isFormPost()) {
            if (page.param(String.class, "action-edits") != null) {
                if (state != null) {
                    Date newPublishDate = page.param(Date.class, "publishDate");

                    if (newPublishDate != null) {
                        Content.ObjectModification contentData = state.as(Content.ObjectModification.class);
                        DateTimeZone timeZone = page.getUserDateTimeZone();
                        newPublishDate = new Date(DateTimeFormat.
                                forPattern("yyyy-MM-dd HH:mm:ss").
                                withZone(timeZone).
                                parseMillis(new DateTime(newPublishDate).toString("yyyy-MM-dd HH:mm:ss")));

                        contentData.setPublishUser(page.getUser());
                        contentData.setPublishDate(newPublishDate);
                        state.save();
                    }
                }

            } else if (page.param(String.class, "action-unlock") != null) {
                contentLock.delete();

                page.writeStart("script", "type", "text/javascript");
                    page.writeRaw("window.location.reload();");
                page.writeEnd();

            } else if (page.param(String.class, "action-settings") != null) {
                try {
                    page.include("/WEB-INF/objectPost.jsp", "object", user, "includeFields", includeFields);
                    user.save();

                } catch (Exception error) {
                    page.getErrors().add(error);
                }
            }
        }

        String returnUrl = page.param(String.class, "returnUrl");

        page.writeHeader();
            page.writeStart("style", "type", "text/css");
                page.writeCss(".cms-contentTools th",
                        "width", "25%;");
            page.writeEnd();

            page.writeStart("div", "class", "widget cms-contentTools");
                page.writeStart("h1", "class", "icon icon-wrench");
                    page.writeHtml("Tools");
                page.writeEnd();

                page.writeStart("div", "class", "tabbed");
                    page.writeStart("div",
                            "class", "fixedScrollable",
                            "data-tab", "For Editors");
                        if (object != null) {
                            Content.ObjectModification contentData = state.as(Content.ObjectModification.class);
                            Date publishDate = contentData.getPublishDate();
                            ToolUser publishUser = contentData.getPublishUser();
                            Date updateDate = contentData.getUpdateDate();
                            ToolUser updateUser = contentData.getUpdateUser();

                            page.writeStart("table", "class", "table-striped");
                                page.writeStart("tbody");
                                    if (publishDate != null || publishUser != null) {
                                        page.writeStart("tr");
View Full Code Here


        if (idle) {
            boolean saveUser = false;

            // Automatically save newly created drafts when the user is idle.
            Content.ObjectModification contentData = state.as(Content.ObjectModification.class);
            ToolUser user = page.getUser();

            if (idle &&
                    (state.isNew() || contentData.isDraft()) &&
                    !page.getCmsTool().isDisableAutomaticallySavingDrafts()) {
                contentData.setDraft(true);
                contentData.setUpdateDate(new Date());
                contentData.setUpdateUser(user);
                state.save();

                Set<UUID> automaticallySavedDraftIds = user.getAutomaticallySavedDraftIds();
                UUID id = state.getId();

                if (!automaticallySavedDraftIds.contains(id)) {
                    saveUser = true;

                    automaticallySavedDraftIds.add(id);
                }
            }

            // Preview for looking glass.
            Preview preview = new Preview();
            UUID currentPreviewId = user.getCurrentPreviewId();

            if (currentPreviewId == null) {
                saveUser = true;
                currentPreviewId = preview.getId();

                user.setCurrentPreviewId(currentPreviewId);
            }

            Map<String, Object> values = state.getSimpleValues();

            preview.getState().setId(currentPreviewId);
            preview.setCreateDate(new Date());
            preview.setObjectType(state.getType());
            preview.setObjectId(state.getId());
            preview.setObjectValues(values);
            preview.setSite(page.getSite());
            preview.save();
            AuthenticationFilter.Static.setCurrentPreview(page.getRequest(), page.getResponse(), preview);
            user.saveAction(page.getRequest(), object);

            if (saveUser) {
                user.save();
            }
        }

        Map<String, Object> jsonResponse = new CompactMap<String, Object>();
View Full Code Here

    private static final long serialVersionUID = 1L;

    @Override
    public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        ToolUser user = AuthenticationFilter.Static.getInsecureToolUser(request);

        if (user == null) {
            throw new IllegalStateException();
        }
View Full Code Here

            if (Boolean.TRUE.equals(request.getAttribute(DATABASE_OVERRIDDEN_ATTRIBUTE))) {
                Database.Static.setIgnoreReadConnection(false);
                Database.Static.restoreDefault();
            }

            ToolUser user = Static.getUser(request);

            if (user != null && Boolean.TRUE.equals(request.getAttribute(USER_SETTINGS_CHANGED_ATTRIBUTE))) {
                user.save();
            }
        }
    }
View Full Code Here

                                toString());

                return true;
            }

            ToolUser user = getUser(request);

            if (user != null) {
                request.setAttribute(AUTHENTICATED_ATTRIBUTE, Boolean.TRUE);

                logIn(request, response, user);
View Full Code Here

                HttpServletRequest request,
                String cookieName,
                String toolUserAttribute,
                String toolUserCheckedAttribute) {

            ToolUser toolUser;

            if (Boolean.TRUE.equals(request.getAttribute(toolUserCheckedAttribute))) {
                toolUser = (ToolUser) request.getAttribute(toolUserAttribute);

            } else {
View Full Code Here

        /**
         * Returns the user setting value associated with the given
         * {@code key}.
         */
        public static Object getUserSetting(HttpServletRequest request, String key) {
            ToolUser user = getUser(request);

            return user != null ? user.getSettings().get(key) : null;
        }
View Full Code Here

        return null;
    }

    @Override
    protected void doService(ToolPageContext page) throws IOException, ServletException {
        ToolUser user = page.getUser();
        Map<String, List<ToolUserDevice>> devicesByUserAgent = new CompactMap<String, List<ToolUserDevice>>();

        for (ToolUserDevice device : Query.
                from(ToolUserDevice.class).
                where("user = ?", user).
View Full Code Here

         * Puts the given user setting {@code value} at the given {@code key}.
         * The user, along with the setting values, are saved once at the end
         * of the given {@code request}.
         */
        public static void putUserSetting(HttpServletRequest request, String key, Object value) {
            ToolUser user = getUser(request);

            if (user != null) {
                user.getSettings().put(key, value);
                request.setAttribute(USER_SETTINGS_CHANGED_ATTRIBUTE, Boolean.TRUE);
            }
        }
View Full Code Here

    }

    @Override
    protected void doService(ToolPageContext page) throws IOException, ServletException {
        if (page.isFormPost()) {
            ToolUser user = page.getUser();
            String name = page.param(String.class, "name");

            if (ObjectUtils.isBlank(name)) {
                throw new IllegalArgumentException("[Name] is required!");
            }

            String search = page.param(String.class, "search");
            int questionAt = search.indexOf('?');

            if (questionAt > -1) {
                search = search.substring(questionAt + 1);
            }

            user.getSavedSearches().put(name, search);
            user.save();

            page.writeStart("div", "id", page.createId());
            page.writeEnd();
            page.writeStart("script", "type", "text/javascript");
                page.writeRaw("$('#").writeRaw(page.getId()).writeRaw("').popup('close');");
View Full Code Here

TOP

Related Classes of com.psddev.cms.db.ToolUser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.