Ejemplo n.º 1
0
    private void Process_CheckInContent()
    {
        string strCallBackPage = "";
        Ektron.Cms.Content.EkContent m_refContent;
        long m_intId;
        StyleHelper m_refStyle = new StyleHelper();
        string AssetFileName = "";
        int contentType = 0;
        try
        {
            m_refContent = m_refContentApi.EkContentRef;
            m_intId = Convert.ToInt64(Request.QueryString["id"].ToString());
            if (!String.IsNullOrEmpty(Request.QueryString["content_type"]))
            {
                contentType = Convert.ToInt32(Request.QueryString["content_type"].ToString());
            }

            switch (contentType)
            {
                case Ektron.Cms.Common.EkConstants.CMSContentType_CatalogEntry:
                    m_refCatalog = new Ektron.Cms.Commerce.CatalogEntry(m_refContentApi.RequestInformationRef);
                    Ektron.Cms.Commerce.EntryData entry = m_refCatalog.GetItemEdit(m_intId, m_refContentApi.RequestInformationRef.ContentLanguage, false);
                    if ((entry != null) && (entry.LastEditorId != m_refContentApi.RequestInformationRef.UserId) && (entry.Status == "O"))
                    {
                        m_refCatalog.TakeOwnershipForAdminCheckIn(m_intId, m_refContentApi.RequestInformationRef.UserId, null);
                    }
                    m_refCatalog.UpdateAndCheckIn(entry);
                    break;
                default:
                    if (!string.IsNullOrEmpty(Request.QueryString["asset_assetfilename"]))
                    {
                        AssetFileName = Request.QueryString["asset_assetfilename"];
                    }
                    ContentData contData = m_refContentApi.GetContentById(m_intId, ContentAPI.ContentResultType.Staged);
                    if ((contData != null) && (contData.UserId != m_refContentApi.RequestInformationRef.UserId) && (contData.Status == "O"))
                    {
                        m_refContent.TakeOwnershipForAdminCheckIn(m_intId);
                    }

                    if ((!string.IsNullOrEmpty(Request.QueryString["content_type"])) && (int.TryParse(Request.QueryString["content_type"], out contentType)) && (Ektron.Cms.Common.EkConstants.IsAssetContentType(contentType, true)))                    {
                        ContentEditData cEditData = m_refContentApi.GetContentForEditing(m_intId);
                        cEditData.FileChanged = false;
                        m_refContentApi.SaveContent(cEditData);
                    }

                    m_refContent.CheckIn(m_intId, AssetFileName);
                    break;
            }
            strCallBackPage = m_refStyle.getCallBackupPage("content.aspx?LangType=" + ContentLanguage + "&action=View&id=" + m_intId);
            Response.Redirect(strCallBackPage, false);
        }
        catch (Exception ex)
        {
            Utilities.ShowError(EkFunctions.UrlEncode(ex.Message));
        }
    }
Ejemplo n.º 2
0
    private void Process_DeleteContent()
    {
        string strCallBackPage = "";
        long m_intId = -1;
        Ektron.Cms.Content.EkContent m_refContent;
        StyleHelper m_refStyle = new StyleHelper();

        m_intId = Convert.ToInt64(Request.QueryString["delete_id"].ToString());
        try
        {
            m_refContent = m_refContentApi.EkContentRef;
            m_intFolderId = Convert.ToInt64(Request.QueryString["folder_id"].ToString());

            Ektron.Cms.Common.EkEnumeration.CMSContentSubtype subtype = m_refContent.GetContentSubType(m_intId);
            if (subtype == Ektron.Cms.Common.EkEnumeration.CMSContentSubtype.PageBuilderMasterData)
            {
                Ektron.Cms.PageBuilder.TemplateModel tm = new Ektron.Cms.PageBuilder.TemplateModel();
                TemplateData td = tm.FindByMasterLayoutID(m_intId);
                if ((td != null) && td.Id > 0)
                {
                    long[] folders = m_refContent.GetTemplateDefaultFolderUsage(td.Id);
                    Collection contentBlockInfo = m_refContent.GetTemplateContentBlockUsage(td.Id);
                    if (folders.Length > 0 || contentBlockInfo.Count > 0)
                    {
                        StringBuilder message = new StringBuilder();
                        message.Append("This master layout cannot be deleted until it is unassigned from the following folders: ");
                        if (folders.Length > 0)
                        {
                            for (int i = 0; i <= folders.Length - 1; i++)
                            {
                                message.Append(m_refContent.GetFolderById(folders[i]).NameWithPath + ", ");
                            }
                        }
                        message.Append("and the following layouts: ");
                        if (contentBlockInfo.Count > 0)
                        {

                            foreach (Collection col in contentBlockInfo)
                            {
                                ContentData content_data = m_refContentApi.EkContentRef.GetContentById(Convert.ToInt64(col["content_id"]), 0);
                                string folderpath = (string)(m_refContent.GetFolderById(content_data.FolderId).NameWithPath);
                                message.Append(folderpath + content_data.Title + ": (id=" + content_data.Id + ", lang=" + content_data.LanguageId + "), ");
                            }
                        }
                        throw (new Exception(message.ToString()));
                    }
                }
            }

            m_refContent.SubmitForDeletev2_0(m_intId, m_intFolderId);
            if (Request.QueryString["page"] == "webpage")
            {
                m_strReloadJS = "<script language=\"Javascript\">";
                m_strReloadJS += "top.opener.location.reload(true);";
                m_strReloadJS += "top.close();";
                m_strReloadJS += "</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "SetAction", m_strReloadJS);
            }
            else
            {
                strCallBackPage = m_refStyle.getCallBackupPage((string)("content.aspx?LangType=" + ContentLanguage + "&action=ViewContentByCategory&id=" + m_intFolderId));
                Response.Redirect(strCallBackPage, false);
            }
        }
        catch (Exception ex)
        {
            Response.Redirect((string)("reterror.aspx?info=" + EkFunctions.UrlEncode(ex.Message)), false);
        }
    }
Ejemplo n.º 3
0
    private void Process_DoSubmit()
    {
        string strCallBackPage = "";
        Ektron.Cms.Content.EkTask m_refTask;
        SettingsData settings_data;
        string strTaskName = "";
        bool IsAlreadyCreated = false;
        Ektron.Cms.Content.EkContent m_refContent;
        long m_intId;
        StyleHelper m_refStyle = new StyleHelper();
        long CurrentUserId;
        long contentType = 0;
        try
        {
            m_intId = Convert.ToInt64(Request.QueryString["id"].ToString());
            m_refContent = m_refContentApi.EkContentRef;
            CurrentUserId = m_refContentApi.UserId;
            m_refTask = m_refContentApi.EkTaskRef;
            if (Convert.ToString(m_intId) != "")
            {
                settings_data = (new SiteAPI()).GetSiteVariables(CurrentUserId);
                contentType = m_refContent.GetContentType(m_intId);

                switch (contentType)
                {
                    case Ektron.Cms.Common.EkConstants.CMSContentType_CatalogEntry:
                        m_refCatalog = new Ektron.Cms.Commerce.CatalogEntry(m_refContentApi.RequestInformationRef);
                        Ektron.Cms.Commerce.EntryData entry = m_refCatalog.GetItemEdit(m_intId, m_refContentApi.RequestInformationRef.ContentLanguage, false);
                        m_refCatalog.Publish(entry, null);
                        break;
                    default:
                        long PreapprovalGroupID;
                        Collection cPreApproval = new Collection();
                        cPreApproval = m_refContent.GetFolderPreapprovalGroup(Convert.ToInt64(Request.QueryString["fldid"].ToString()));
                        PreapprovalGroupID = System.Convert.ToInt32(cPreApproval["UserGroupID"]);

                        if (PreapprovalGroupID > 0)
                        {
                            if (ContentLanguage == Ektron.Cms.Common.EkConstants.ALL_CONTENT_LANGUAGES) //1 removed with ALL_CONTENT_LANGUAGES
                            {
                                strTaskName = (string)(Request.Form["content_title"] + m_intId + "_Task");
                            }
                            else
                            {
                                strTaskName = (string)(Request.Form["content_title"] + m_intId + "_Task" + ContentLanguage);
                            }
                            m_refTask.ContentLanguage = ContentLanguage;
                            m_refTask.LanguageID = ContentLanguage;
                            IsAlreadyCreated = m_refTask.IsTaskAlreadyCreated(m_intId);
                            if (IsAlreadyCreated == false)
                            {
                                m_refTask.LanguageID = ContentLanguage;
                                m_refTask.TaskTitle = strTaskName; // Task name would be contentname + content id + _Task
                                m_refTask.AssignToUserGroupID = PreapprovalGroupID; //Assigned to group defined by gtTaskAssignGroup
                                m_refTask.AssignedByUserID = CurrentUserId.ToString(); //Assigned by person creating the task
                                m_refTask.State = "1"; //Not started
                                m_refTask.ContentID = m_intId; //Content m_intId of the content being created
                                m_refTask.Priority = EkEnumeration.TaskPriority.Normal; //Normal
                                m_refTask.CreatedByUserID = CurrentUserId; //If task hops this will always be created user
                                m_refTask.AddTask();
                                m_refContent.SetContentState(m_intId, "T");
                            }
                            else
                            {
                                m_refContent.SubmitForPublicationv2_0(m_intId, Convert.ToInt64(Request.QueryString["fldid"].ToString()), "");
                            }
                        }
                        else
                        {
                            m_refContent.SubmitForPublicationv2_0(m_intId, Convert.ToInt64(Request.QueryString["fldid"].ToString()), "");
                        }
                        break;
                }
            }
            strCallBackPage = m_refStyle.getCallBackupPage("content.aspx?LangType=" + ContentLanguage + "&action=View&id=" + m_intId + "&fldid=" + Request.QueryString["fldid"]);
            Response.Redirect(strCallBackPage, false);
        }
        catch (Exception ex)
        {
            Utilities.ShowError(ex.Message);
        }
    }