Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string CultureCode = (Page as DotNetNuke.Framework.PageBase).PageCulture.Name;
                string Title = ((DotNetNuke.Framework.CDefault)this.Page).Title;

                if(Title[0]=='C')
                {
                    Title = Title.Replace("C", "");
                    int CourseId = Convert.ToInt32(Title);
                    CourseContainer cc = new CourseContainer(CultureCode, CourseId);
                    if(cc.TheCourse.CreatedInCultureCode != CultureCode)
                    {
                        cc.LoadTitle();
                        lblTitle.Text = cc.TheTitle.Text;
                    }
                }
                else
                {
                    int PluggId = Convert.ToInt32(Title);
                    PluggContainer pc = new PluggContainer(CultureCode, PluggId);
                    if (pc.ThePlugg.CreatedInCultureCode != CultureCode)
                    {
                        pc.LoadTitle();
                        lblTitle.Text = pc.TheTitle.Text;
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     switch (SubjectCase )
     {
         case ESubjectCase.Plugg:
             PluggContainer pc = new PluggContainer(CultureCode, ItemId);
             if (pc.ThePlugg != null && pc.ThePlugg.PluggId != 0)
             {
                 pc.ThePlugg.SubjectId = Convert.ToInt32(hdnNodeSubjectId.Value);
                 pc.UpdatePluggEntity();
             }
             Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "", "edit=0", AttachQS));
             break;
         case ESubjectCase.Course:
             CourseContainer cc = new CourseContainer(CultureCode, ItemId);
             if (cc.TheCourse != null && cc.TheCourse.CourseId != 0)
             {
                 cc.TheCourse.SubjectId = Convert.ToInt32(hdnNodeSubjectId.Value);
                 cc.UpdateCourseEntity();
             }
             Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "", "edit=0", AttachQS));
             break;
         case ESubjectCase.NotSet:
             throw new Exception("Subject case not set");
             break;
     }
 }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     BaseHandler bh = new BaseHandler();
     PHText t = bh.GetCurrentVersionText(CultureCode, ItemId, ItemType);
     if (t == null)
     {
         t = new PHText();
         t.CreatedByUserId = UserId;
         t.CultureCode = CultureCode;
         t.ItemId = ItemId;
         t.ItemType = ItemType;
     }
     t.Text = Regex.Replace(tbTheText.Text, "<[^>]*>", String.Empty);
     t.ModifiedByUserId = UserId;
     if (Case == EControlCase.Edit)
     {
         bh.SavePhTextInAllCc(t);
         if (ItemType == ETextItemType.PluggTitle)
         {
             string newPageName = ItemId.ToString() + ": " + t.Text;
             PluggContainer pc = new PluggContainer(CultureCode, ItemId);
             DNNHelper h = new DNNHelper();
             h.RenameTab(pc.ThePlugg.TabId, newPageName);
         }
         if (ItemType == ETextItemType.CourseTitle)
         {
             string newPageName = "C" + ItemId.ToString() + ": " + t.Text;
             CourseContainer cc = new CourseContainer(CultureCode, ItemId);
             DNNHelper h = new DNNHelper();
             h.RenameTab(cc.TheCourse.TabId, newPageName);
         }
         Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "", "edit=0", AttachQS));
     }
     else if (Case == EControlCase.Translate)
     {
         t.CultureCodeStatus = ECultureCodeStatus.HumanTranslated;
         bh.SavePhText(t);
         Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "", "translate=0", AttachQS));
     }
 }
Ejemplo n.º 4
0
        public void CreateCourse(CourseContainer c)
        {
            if (c.CultureCode == null || c.CultureCode == "")
                throw new Exception("Cannot Create Course. CutureCode cannot be null");

            if (c.TheTitle == null || c.TheTitle.Text == null || c.TheTitle.Text == "")
                throw new Exception("Cannot Save Course. Title cannot be null");

            c.TheCourse.CreatedInCultureCode = c.CultureCode;
            c.TheCourse.CreatedOnDate = DateTime.Now;
            c.TheCourse.ModifiedByUserId = c.TheCourse.CreatedByUserId;
            c.TheCourse.ModifiedOnDate = c.TheCourse.CreatedOnDate;
            c.TheCourse.IsDeleted = false;
            c.TheCourse.IsListed = true;

            bool isNew = c.TheCourse.CourseId == 0;

            if (isNew)
            {
                rep.CreateCourse(c.TheCourse);
            }
            else
                rep.UpdateCourse(c.TheCourse);

            //Save Title
            c.TheTitle.ItemId = c.TheCourse.CourseId;
            c.TheTitle.ItemType = ETextItemType.CourseTitle;
            c.TheTitle.CultureCode = c.CultureCode;
            c.TheTitle.CultureCodeStatus = ECultureCodeStatus.InCreationLanguage;
            c.TheTitle.CreatedByUserId = c.TheCourse.CreatedByUserId;
            c.TheTitle.ModifiedByUserId = c.TheCourse.ModifiedByUserId;
            SavePhTextInAllCc(c.TheTitle);  //Save or Update

            //Save Description
            if (c.TheDescription != null && c.TheDescription.Text != null && c.TheDescription.Text != "")
            {
                c.TheDescription.ItemId = c.TheCourse.CourseId;
                c.TheDescription.ItemType = ETextItemType.CourseDescription;
                c.TheDescription.CultureCode = c.CultureCode;
                c.TheDescription.CultureCodeStatus = ECultureCodeStatus.InCreationLanguage;
                c.TheDescription.CreatedByUserId = c.TheCourse.CreatedByUserId;
                c.TheDescription.ModifiedByUserId = c.TheCourse.ModifiedByUserId;
                SavePhTextInAllCc(c.TheDescription);
            }
            if (c.TheRichRichText != null && c.TheRichRichText.Text != null && c.TheRichRichText.Text != "")
            {
                c.TheRichRichText.ItemId = c.TheCourse.CourseId;
                c.TheRichRichText.ItemType = ETextItemType.CourseRichRichText;
                c.TheRichRichText.CultureCode = c.CultureCode;
                c.TheRichRichText.CultureCodeStatus = ECultureCodeStatus.InCreationLanguage;
                c.TheRichRichText.CreatedByUserId = c.TheCourse.CreatedByUserId;
                c.TheRichRichText.ModifiedByUserId = c.TheCourse.ModifiedByUserId;
                SavePhTextInAllCc(c.TheRichRichText);
            }
            //Create CoursePage
            if (isNew)
            {
                DNNHelper d = new DNNHelper();
                string pageUrl = "C" + c.TheCourse.CourseId.ToString();
                string pageName = pageUrl + ": " + c.TheTitle.Text;
                TabInfo newTab = d.AddCoursePage(pageName, pageUrl);
                c.TheCourse.TabId = newTab.TabID;
                rep.UpdateCourse(c.TheCourse);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string coursePageName = ((DotNetNuke.Framework.CDefault)this.Page).Title;
            coursePageName = coursePageName.Replace("C", "");
            CourseId = Convert.ToInt32(coursePageName);
            CultureCode = (Page as DotNetNuke.Framework.PageBase).PageCulture.Name;
            BaseHandler bh = new BaseHandler();
            cc = new CourseContainer(CultureCode, CourseId);
            IsAuthorized = ((this.UserId != -1 && cc.TheCourse.WhoCanEdit == EWhoCanEdit.Anyone) || cc.TheCourse.CreatedByUserId == this.UserId || (UserInfo.IsInRole("Administator")));

            if (Request.Form["__EVENTTARGET"] == "btnWhoCanEdit")
            {
                // Fire event
                btnWhoCanEdit_Click(this, new EventArgs());
            }

            if (Request.Form["__EVENTTARGET"] == "btnListed")
            {
                // Fire event
                btnListed_Click(this, new EventArgs());
            }

            UserController uc = new UserController();
            UserInfo u = uc.GetUser(PortalId, cc.TheCourse.CreatedByUserId);
            hlCreatedBy.Text = u.DisplayName;
            hlCreatedBy.NavigateUrl = DotNetNuke.Common.Globals.UserProfileURL(cc.TheCourse.CreatedByUserId);
            lbltheCreatedOn.Text = cc.TheCourse.CreatedOnDate.ToString();
            rblWhoCanEdit.Items.Clear();
            rblWhoCanEdit.Items.Add("Anyone");
            rblWhoCanEdit.Items.Add("Only me");
            rblWhoCanEdit.SelectedValue = "Anyone";
            switch (cc.TheCourse.WhoCanEdit)
            {
                case EWhoCanEdit.Anyone:
                    lbltheWhoCanEdit.Text = "Anyone";
                    break;
                case EWhoCanEdit.OnlyMe:
                    lbltheWhoCanEdit.Text = "Only me";
                    rblWhoCanEdit.SelectedValue = "Only me";
                    break;
                case EWhoCanEdit.NotSet :
                    lbltheWhoCanEdit.Text = "Not set";
                    break;
            }
            rblListed.Items.Clear();
            rblListed.Items.Add(Localization.GetString("Listed.Text", this.LocalResourceFile));
            rblListed.Items.Add(Localization.GetString("NotListed.Text", this.LocalResourceFile));
            rblListed.SelectedIndex = 0;

            if (cc.TheCourse.IsListed)
                lblTheListed.Text = "Yes";
            else
            {
                lblTheListed.Text = "No";
                rblListed.SelectedIndex = 1;
            }
            if (cc.TheCourse.CreatedByUserId == this.UserId)
            {
                btnWhoCanEdit.Visible = true;
                btnListed.Visible = true;
            }
            cc.LoadDescription();
            if (cc.TheDescription != null)
                lbltheDespription.Text = cc.TheDescription.Text;
            else
                lbltheDespription.Text = "-";

            if(cc.TheCourse.CreatedByUserId == this.UserId || UserInfo.IsInRole("Administator"))
            {
                btnDelete.Visible = true;
            }
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Language = (Page as DotNetNuke.Framework.PageBase).PageCulture.Name;
                string courseStr = Page.Request.QueryString["c"];
                if (courseStr == null)
                {
                    HideButtons();
                    return;
                }
                bool isNum = int.TryParse(courseStr, out CourseId);
                if (!isNum)
                {
                    HideButtons();
                    return;
                }
                BaseHandler bh = new BaseHandler();
                CourseContainer cc = new CourseContainer(Language, CourseId);
                if (cc.TheCourse == null)
                {
                    HideButtons();
                    return;
                }
                hlBackToCourse.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(cc.TheCourse.TabId, "", "");
                if (cc.TheCourse.CreatedInCultureCode != Language)
                {
                    hlIncorrectCC.Visible = true;
                    hlIncorrectCC.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "language=" + cc.TheCourse.CreatedInCultureCode, "c=" + CourseId);
                    HideButtons();
                    return;
                }
                string editStr = Page.Request.QueryString["edit"];
                bool IsAuthorized = ((this.UserId != -1 && cc.TheCourse.WhoCanEdit == EWhoCanEdit.Anyone) || cc.TheCourse.CreatedByUserId == this.UserId || (UserInfo.IsInRole("Administator")));

                if (!IsAuthorized)
                {
                    HideButtons();
                    BindTree();
                }
                if (editStr == "reorder")
                {
                    HideButtons();
                    btnSaveReordering.Visible = true;
                    btnCancelReordering.Visible = true;
                    hdnSelectable.Value = "true";
                    hdnDragAndDrop.Value = "true";
                }
                if (editStr == "add")
                {
                    HideButtons();
                    hdnSelectable.Value = "true";
                    pnlAddPluggs.Visible = true;
                }
                if (editStr == "remove")
                {
                    HideButtons();
                    hdnSelectable.Value = "true";
                    btnRemoveSelectedPlugg.Visible = true;
                    btnCancelRemove.Visible = true;
                }
                BindTree();
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 7
0
 private void CreateCourse()
 {
     string cultureCode = (Page as DotNetNuke.Framework.PageBase).PageCulture.Name;
     CourseContainer cc = new CourseContainer(cultureCode);
     cc.TheCourse.CreatedByUserId = UserId;
     cc.TheCourse.ModifiedByUserId = UserId;
     cc.TheCourse.CourseId = 0;
     cc.TheCourse.CreatedInCultureCode = cultureCode;
     cc.SetTitle(Regex.Replace(nvc["Title"], "<[^>]*>", String.Empty));
     //string subjectStr = Page.Request.QueryString["s"];
     //if (subjectStr != null)
     //{
     //    int subid = Convert.ToInt32(subjectStr);
     //    pc.ThePlugg.SubjectId = subid;
     //}
     //else
     //    pc.ThePlugg.SubjectId = 0;
     cc.TheCourse.SubjectId = 0;
     if (nvc["Description"] != "")
         cc.SetDescription(Regex.Replace(nvc["Description"], "<[^>]*>", String.Empty));
     cc.TheCourse.WhoCanEdit = EWhoCanEdit.Anyone;
     BaseHandler bh = new BaseHandler();
     bh.CreateCourse(cc);
     Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(cc.TheCourse.TabId, "", "edit=0"));
 }
Ejemplo n.º 8
0
        protected CourseContainer SaveCourse()
        {
            BaseHandler bh = new BaseHandler();
            CourseContainer cc = new CourseContainer(new Localization().CurrentCulture);
            List<CourseItemEntity> cis = new List<CourseItemEntity>();
            ReadFromControls(cc, cis);
            try
            {
                bh.CreateCourse(cc);  //Create CoursePage, Course and CourseItems (only Pluggs)
            }
            catch (Exception ex)
            {
                lblError.Text = "Failed to create a Course: " + ex.Message;
                Exceptions.LogException(ex);
                cc.TheCourse.CourseId = 0;
            }

            return cc;
        }
Ejemplo n.º 9
0
        protected void ReadFromControls(CourseContainer c, List<CourseItemEntity> cis)
        {
            string subjectStr = Page.Request.QueryString["s"];
            if (subjectStr != null)
            {
                int subjectId;
                bool isNum = int.TryParse(subjectStr, out subjectId);
                if (isNum)
                    c.TheCourse.SubjectId = subjectId;
            }

            c.SetTitle(txtTitle.Text);
            c.CultureCode = DDLanguage.SelectedValue;
            c.TheCourse.WhoCanEdit = (EWhoCanEdit)Enum.Parse(typeof(EWhoCanEdit), rdbtnWhoCanEdit.SelectedValue);
            c.TheCourse.CreatedOnDate = DateTime.Now;
            c.TheCourse.CreatedByUserId = this.UserId;
            c.TheCourse.ModifiedOnDate = DateTime.Now; ;
            c.TheCourse.ModifiedByUserId = this.UserId;
            c.SetDescription(txtHtmlText.Text);

            // string is in form "44,45,48,52" holding PluggIDs
            string pluggtext = txtPluggs.Text.Trim();

            // Todo: Check that pluggtext is in the correct format before creating the Course

            CourseItemEntity ci;
            if (!string.IsNullOrEmpty(pluggtext))
            {
                string[] itempluggs = pluggtext.Split(',');

                for (int i = 0; i < itempluggs.Length; i++)
                {
                    ci = new CourseItemEntity();
                    ci.ItemId = Convert.ToInt32(itempluggs[i]);
                    ci.CIOrder = i + 1;
                    ci.ItemType = ECourseItemType.Plugg;
                    ci.MotherId = 0;
                    cis.Add(ci);
                }
            }
        }
Ejemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string coursePageName = ((DotNetNuke.Framework.CDefault)this.Page).Title;
                coursePageName = coursePageName.Replace("C", "");
                CourseId = Convert.ToInt32(coursePageName);
                CultureCode = (Page as DotNetNuke.Framework.PageBase).PageCulture.Name;
                BaseHandler bh = new BaseHandler();
                cc = new CourseContainer(CultureCode, CourseId);
                if (cc.TheCourse.IsDeleted)
                    Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(Convert.ToInt32(Localization.GetString("TabCourseDeleted.Text", LocalResourceFile))));
                InCreationLanguage = (cc.TheCourse.CreatedInCultureCode == CultureCode);
                IsAuthorized = ((this.UserId != -1 && cc.TheCourse.WhoCanEdit == EWhoCanEdit.Anyone) || cc.TheCourse.CreatedByUserId == this.UserId || (UserInfo.IsInRole("Administator")));
                Edit = !string.IsNullOrEmpty(Page.Request.QueryString["edit"]) ? Convert.ToInt16(Page.Request.QueryString["edit"]) : -1;
                Translate = !string.IsNullOrEmpty(Page.Request.QueryString["translate"]) ? Convert.ToInt16(Page.Request.QueryString["translate"]) : -1;
                DisplayInfo = !string.IsNullOrEmpty(Page.Request.QueryString["info"]) ? Convert.ToInt16(Page.Request.QueryString["info"]) : -1;
                bool editOrTranslateMode = (Edit > -1 || Translate > -1) && UserId > -1;

                #region hide/display controls
                hlDisplayInfo.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "info=0");
                if (DisplayInfo == 0)
                {
                    pnlDisplayInfo.Visible = false;
                    pnlHideDisplayInfo.Visible = true;
                    hlHideDisplayInfo.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "");
                }

                if (!InCreationLanguage && UserId > -1 && Translate == -1)
                {
                    pnlToCreationLanguage.Visible = true;
                    hlToCreationLanguage.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "language=" + cc.TheCourse.CreatedInCultureCode);
                    pnlTranslatePlugg.Visible = true;
                    hlTranslatePlugg.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "translate=0");
                }

                if (InCreationLanguage && UserId > -1 && Edit == -1)
                {
                    pnlEditPlugg.Visible = true;
                    hlEditPlugg.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "edit=0");
                }

                if (!InCreationLanguage && UserId > -1 && Translate > -1)
                {
                    pnlExitTranslateMode.Visible = true;
                    hlExitTranslateMode.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "");
                }

                if (InCreationLanguage && UserId > -1 && Edit > -1)
                {
                    pnlExitEditMode.Visible = true;
                    hlExitEditMode.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "");
                }

                if (Edit == 0)
                {
                    plEditPluggs.Visible = true;
                    hlEditPluggs.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(133, "", "c=" + CourseId); //"/PAndC/Edit-CP/c/" + CourseId;
                }

                cc.LoadPluggs();
                if (cc.ThePluggs.Count == 0)
                {
                    lblNoPluggs.Visible = true;
                    lnkBeginCourse.Enabled = false;
                }
                else
                {
                    PluggContainer pc = new PluggContainer(CultureCode, cc.ThePluggs[0].PluggId);
                    lnkBeginCourse.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(pc.ThePlugg.TabId, "", "cp=" + cc.ThePluggs[0].CoursePluggId);
                }
                #endregion

                phComponents.Controls.Clear();
                int controlOrder = 1;

                if (DisplayInfo == 0)
                {
                    DisplayCourseInfo ucDCI = (DisplayCourseInfo)this.LoadControl("/DesktopModules/DisplayCourse/DisplayCourseInfo.ascx");
                    if (ucDCI != null)
                    {
                        ucDCI.LocalResourceFile = "/DesktopModules/DisplayCourse/App_LocalResources/DisplayCourseInfo.ascx";
                        phComponents.Controls.Add(ucDCI);
                    }
                }

                if (editOrTranslateMode)
                {
                    string ComponentHead = "<hr /><h3>" + Localization.GetString("Subject", LocalResourceFile) + "</h3>";
                    phComponents.Controls.Add(new LiteralControl(ComponentHead));
                }
                LoadSubject(controlOrder);
                controlOrder++;

                if (editOrTranslateMode)
                {
                    string ComponentHead = "<hr /><h3>" + Localization.GetString("Title", LocalResourceFile) + "</h3>";
                    phComponents.Controls.Add(new LiteralControl(ComponentHead));
                    EditTitleAndDescription(controlOrder, ETextItemType.CourseTitle);
                    controlOrder++;

                    ComponentHead = "<hr /><h3>" + Localization.GetString("Description", LocalResourceFile) + "</h3>";
                    phComponents.Controls.Add(new LiteralControl(ComponentHead));
                    EditTitleAndDescription(controlOrder, ETextItemType.CourseDescription );
                    controlOrder++;
                }

                if (editOrTranslateMode)
                {
                    string ComponentHead = "<hr /><h3>" + Localization.GetString("Content", LocalResourceFile) + "</h3>";
                    phComponents.Controls.Add(new LiteralControl(ComponentHead));
                }

                LoadRichRich(controlOrder);

            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    BaseHandler bh = new BaseHandler();
                    CultureCode = (Page as DotNetNuke.Framework.PageBase).PageCulture.Name;
                    PluggId = Convert.ToInt32(((DotNetNuke.Framework.CDefault)this.Page).Title);

                    string coursePluggIdStr = Page.Request.QueryString["cp"];
                    if (coursePluggIdStr == null)    //This is a Plugg outside a course: no menu
                        return;

                    bool isNum = int.TryParse(coursePluggIdStr, out CoursePluggId);
                    if (!isNum)
                        return;

                    currentCPE = bh.GetCPEntity(CoursePluggId);
                    if (currentCPE == null)
                        return;
                    CourseId = currentCPE.CourseId;
                    cc = new CourseContainer(CultureCode, CourseId);
                    if (cc == null)
                        return;
                    pnlTitle.Visible = true;
                    hlBackToCourse.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(cc.TheCourse.TabId, "", "");
                    cc.LoadPluggs();
                    CoursePlugg currentCP = bh.FindCoursePlugg(CultureCode, CourseId, CoursePluggId);
                    CoursePlugg nextCP = bh.NextCoursePlugg(currentCP);
                    if (nextCP != null)
                    {
                        PluggContainer p = new PluggContainer(CultureCode, nextCP.PluggId);
                        lnkNextPlugg.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(p.ThePlugg.TabId, "", "cp=" + nextCP.CoursePluggId );
                    }
                    else
                    {
                        lnkNextPlugg.Enabled = false;
                    }

                    PopulateTreeNodes((List<CoursePlugg>)cc.ThePluggs, TreeViewMain.Nodes);
                }

            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string CourseTitle = ((DotNetNuke.Framework.CDefault)this.Page).Title;//get Course from page title
                CourseTitle = CourseTitle.Replace("C", "");

                if (!string.IsNullOrEmpty(CourseTitle))
                {
                    Courseid = Convert.ToInt32(CourseTitle);
                }
                curlan = (Page as DotNetNuke.Framework.PageBase).PageCulture.Name;

                cc = new CourseContainer(curlan, Courseid);

                CallLocalization();
                EditStr = Page.Request.QueryString["edit"];
                IsAuthorized = (cc.TheCourse.WhoCanEdit == EWhoCanEdit.Anyone || cc.TheCourse.CreatedByUserId == this.UserId || UserInfo.IsInRole("Administator"));
                if (this.UserId == -1)
                {
                    IsAuthorized = false;
                }
                IsCase3 = (EditStr == "1" && IsAuthorized);
                IsCase2 = (EditStr == "2" && IsAuthorized);

                BaseHandler bh = new BaseHandler();

                if (cc.TheDescription == null)
                    cc.LoadDescription();

                if (cc.TheTitle == null)
                    cc.LoadTitle();

                LoadRichRichText();

                lblDescription.Text = Server.HtmlDecode(cc.TheDescription.Text);
                lblTitle.Text = Server.HtmlDecode(cc.TheTitle.Text);
                lblRichRichTxt.Text = Server.HtmlDecode(cc.TheRichRichText.Text);

                BindTree(cc.TheCourse.SubjectId);

                PageLoadFun();
            }

            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                BaseHandler bh = new BaseHandler();
                CultureCode = (Page as DotNetNuke.Framework.PageBase).PageCulture.Name;

                string coursePluggIdStr = Page.Request.QueryString["cp"];
                if (coursePluggIdStr == null)    //This is a Plugg outside a course: no menu
                    return;

                bool isNum = int.TryParse(coursePluggIdStr, out CoursePluggId);
                if (!isNum)
                    return;

                currentCPE = bh.GetCPEntity(CoursePluggId);
                if (currentCPE == null)
                    return;
                CourseId = currentCPE.CourseId;
                cc = new CourseContainer(CultureCode, CourseId);
                if (cc == null)
                    return;

                InCreationLanguage = (cc.TheCourse.CreatedInCultureCode == CultureCode);
                IsAuthorized = ((this.UserId != -1 && cc.TheCourse.WhoCanEdit == EWhoCanEdit.Anyone) || cc.TheCourse.CreatedByUserId == this.UserId || (UserInfo.IsInRole("Administator")));
                Edit = !string.IsNullOrEmpty(Page.Request.QueryString["editcp"]) ? Convert.ToInt16(Page.Request.QueryString["editcp"]) : -1;
                Translate = !string.IsNullOrEmpty(Page.Request.QueryString["translatecp"]) ? Convert.ToInt16(Page.Request.QueryString["translatecp"]) : -1;

                PHText theComment = bh.GetCurrentVersionText(CultureCode, CoursePluggId, ETextItemType.CoursePluggText);
                if (theComment != null && Edit == -1 && Translate == -1)
                    TheText.Text = theComment.Text;

                #region hide/display controls
                if (!InCreationLanguage && UserId > -1 && Translate == -1)
                {
                    phTranslate.Visible = true;
                    hlTranslate.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "translatecp=0", "cp=" + CoursePluggId);
                }

                if (InCreationLanguage && IsAuthorized && Edit == -1)
                {
                    phEditCPComment.Visible = true;
                    if (theComment==null)
                        hlEditCPComment.Text = Localization.GetString("AddCPComment", this.LocalResourceFile);
                    else
                        hlEditCPComment.Text = Localization.GetString("EditCPComment", this.LocalResourceFile);
                    hlEditCPComment.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "editcp=0", "cp=" + CoursePluggId);
                }

                if (!InCreationLanguage && UserId > -1 && Translate > -1)
                {
                    phExitTranslate.Visible = true;
                    hlExitTranslate.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "cp=" + CoursePluggId);
                    RichControl ucR = (RichControl)this.LoadControl("/DesktopModules/PlugghestControls/RichControl.ascx");
                    if ((ucR != null))
                    {
                        ucR.ModuleConfiguration = this.ModuleConfiguration;
                        ucR.ItemId = CoursePluggId;
                        ucR.CultureCode = CultureCode;
                        ucR.CreatedInCultureCode = CultureCode;
                        ucR.CreatedInCultureCode = cc.TheCourse.CreatedInCultureCode;
                        ucR.ControlOrder = 1;
                        ucR.ItemType = ETextItemType.CoursePluggText;
                        ucR.Case = EControlCase.ViewAllowTranslate;
                        if (Translate == 1)
                            ucR.Case = EControlCase.Translate;
                        ucR.LocalResourceFile = "/DesktopModules/PlugghestControls/App_LocalResources/RichControl.ascx";
                        phTheText.Controls.Add(ucR);
                    }
                }

                if (InCreationLanguage && IsAuthorized && Edit > -1)
                {
                    plInfo.Visible = true;
                    RichControl ucR = (RichControl)this.LoadControl("/DesktopModules/PlugghestControls/RichControl.ascx");
                    if ((ucR != null))
                    {
                        ucR.ModuleConfiguration = this.ModuleConfiguration;
                        ucR.ItemId = CoursePluggId;
                        ucR.CultureCode = CultureCode;
                        ucR.CreatedInCultureCode = CultureCode;
                        ucR.ControlOrder = 1;
                        ucR.ItemType = ETextItemType.CoursePluggText;
                        ucR.Case = EControlCase.Edit;
                        ucR.LocalResourceFile = "/DesktopModules/PlugghestControls/App_LocalResources/RichControl.ascx";
                        phTheText.Controls.Add(ucR);
                    }
                }
                #endregion

            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }