private void agFilters_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e)
        {
            try
            {
                if (!(e.Parameters[4] == ""))
                {
                    string sAction  = e.Parameters[4].Split(':')[0];
                    int    FilterId = Convert.ToInt32(e.Parameters[4].Split(':')[1]);
                    switch (sAction.ToUpper())
                    {
                    case "DELETE":
                        if (SimulateIsNumeric.IsNumeric(FilterId))
                        {
                            DataProvider.Instance().Filters_Delete(PortalId, ModuleId, FilterId);
                        }
                        break;

                    case "DEFAULTS":
                        DataProvider.Instance().Filters_DeleteByModuleId(PortalId, ModuleId);
                        Utilities.ImportFilter(PortalId, ModuleId);
                        break;
                    }
                }
                int    PageIndex  = Convert.ToInt32(e.Parameters[0]);
                int    PageSize   = Convert.ToInt32(e.Parameters[1]);
                string SortColumn = e.Parameters[2].ToString();
                string Sort       = e.Parameters[3].ToString();
                agFilters.Datasource = DataProvider.Instance().Filters_List(PortalId, ModuleId, PageIndex, PageSize, Sort, SortColumn);
                agFilters.Refresh(e.Output);
            }
            catch (Exception ex)
            {
            }
        }
        private void agTags_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e)
        {
            try
            {
                if (!(e.Parameters[4] == ""))
                {
                    string sAction = e.Parameters[4].Split(':')[0];

                    switch (sAction.ToUpper())
                    {
                    case "DELETE":
                    {
                        int TagId = Convert.ToInt32(e.Parameters[4].Split(':')[1]);
                        if (SimulateIsNumeric.IsNumeric(TagId))
                        {
                            DataProvider.Instance().Tags_Delete(PortalId, ModuleId, TagId);
                        }
                        break;
                    }

                    case "SAVE":
                    {
                        string[] sParams = e.Parameters[4].Split(':');
                        string   TagName = sParams[1].Trim();
                        int      TagId   = 0;
                        if (sParams.Length > 2)
                        {
                            TagId = Convert.ToInt32(sParams[2]);
                        }
                        if (!(TagName == string.Empty))
                        {
                            DataProvider.Instance().Tags_Save(PortalId, ModuleId, TagId, TagName, 0, 0, 0, -1, false, -1, -1);
                        }



                        break;
                    }
                    }
                }
                agTags.DefaultParams = string.Empty;
                int    PageIndex  = Convert.ToInt32(e.Parameters[0]);
                int    PageSize   = Convert.ToInt32(e.Parameters[1]);
                string SortColumn = e.Parameters[2].ToString();
                string Sort       = e.Parameters[3].ToString();
                agTags.Datasource = DataProvider.Instance().Tags_List(PortalId, ModuleId, false, PageIndex, PageSize, Sort, SortColumn, -1, -1);
                agTags.Refresh(e.Output);
            }
            catch (Exception ex)
            {
            }
        }
 private void cbRating_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e)
 {
     if (e.Parameters.Length > 0)
     {
         int rate = Convert.ToInt32(e.Parameter);
         if (rate >= 1 && rate <= 5)
         {
             DataProvider.Instance().Topics_AddRating(TopicId, UserId, rate, string.Empty, Request.UserHostAddress.ToString());
         }
     }
     Rating = -1;
     RenderRating();
     plhRating.RenderControl(e.Output);
 }
Esempio n. 4
0
        private void cbGrid_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e)
        {
            int objectId = Convert.ToInt32(e.Parameters[1]);
            int dir      = Convert.ToInt32(e.Parameters[2]);

            switch (e.Parameters[0].ToString().ToLower())
            {
            case "g":
                DataProvider.Instance().Groups_Move(ModuleId, objectId, dir);
                break;

            case "f":
                DataProvider.Instance().Forums_Move(ModuleId, objectId, dir);
                break;
            }
            BindForums();
            litForums.RenderControl(e.Output);
        }
Esempio n. 5
0
 private void cbAdmin_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e)
 {
     if (!(CurrentUserType == CurrentUserTypes.Anon) && !(CurrentUserType == CurrentUserTypes.Auth))
     {
         UserProfileController upc = new UserProfileController();
         UserController        uc  = new UserController();
         UserProfileInfo       upi = uc.GetUser(PortalId, ForumModuleId, UID).Profile;
         if (upi != null)
         {
             upi.RewardPoints      = Convert.ToInt32(e.Parameters[1]);
             upi.UserCaption       = e.Parameters[2].ToString();
             upi.SignatureDisabled = Convert.ToBoolean(e.Parameters[3]);
             upi.AvatarDisabled    = Convert.ToBoolean(e.Parameters[4]);
             upi.TrustLevel        = Convert.ToInt32(e.Parameters[5]);
             upi.AdminWatch        = Convert.ToBoolean(e.Parameters[6]);
             upi.AttachDisabled    = Convert.ToBoolean(e.Parameters[7]);
             upc.Profiles_Save(upi);
         }
     }
 }
        private void cbMyFiles_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e)
        {
            string attachIds = e.Parameters[1].ToString();

            switch (e.Parameters[0].ToLowerInvariant())
            {
            case "del":
                if (SimulateIsNumeric.IsNumeric(e.Parameters[2]))
                {
                    int aid = Convert.ToInt32(e.Parameters[2]);
                    Data.AttachController ac = new Data.AttachController();
                    int uid = -1;
                    if (SimulateIsNumeric.IsNumeric(e.Parameters[3]))
                    {
                        uid = Convert.ToInt32(e.Parameters[3]);
                    }
                    if ((uid == this.UserId && !(this.UserId == -1)) | Permissions.HasPerm(ForumInfo.Security.ModDelete, ForumUser.UserRoles) || UserInfo.IsSuperUser)
                    {
                        ac.Attach_Delete(aid, -1, uid);
                    }
                }


                break;
            }
            PendingAttach = 0;
            plhMyFiles.Controls.Clear();
            BindMyFiles();
            System.IO.StringWriter stringWriter = new System.IO.StringWriter();
            HtmlTextWriter         htmlWriter   = new HtmlTextWriter(stringWriter);

            plhMyFiles.RenderControl(htmlWriter);
            string html = stringWriter.GetStringBuilder().ToString();

            html = Utilities.LocalizeControl(html);
            LiteralControl lit = new LiteralControl();

            lit.Text = html;
            lit.RenderControl(e.Output);
        }
Esempio n. 7
0
        private void cbMod_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e)
        {
            SettingsInfo ms = DataCache.MainSettings(ForumModuleId);
            Forum        fi = null;

            if (e.Parameters.Length > 0)
            {
                if (ForumId < 1)
                {
                    SetPermissions(Convert.ToInt32(e.Parameters[1]));
                    ForumController fc = new ForumController();
                    fi = fc.Forums_Get(Convert.ToInt32(e.Parameters[1]), -1, false, true);
                }
                else
                {
                    fi = ForumInfo;
                }
                switch (e.Parameters[0].ToLowerInvariant())
                {
                case "moddel":
                {
                    if (bModDelete)
                    {
                        int delAction  = ms.DeleteBehavior;
                        int tmpForumId = -1;
                        int tmpTopicId = -1;
                        int tmpReplyId = -1;
                        tmpForumId = Convert.ToInt32(e.Parameters[1]);
                        tmpTopicId = Convert.ToInt32(e.Parameters[2]);
                        tmpReplyId = Convert.ToInt32(e.Parameters[3]);
                        Author auth = null;
                        if (fi.ModDeleteTemplateId > 0)
                        {
                            try
                            {
                                //Email.SendEmail(fi.ModDeleteTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, auth);
                                Email.SendEmailToModerators(fi.ModDeleteTemplateId, PortalId, tmpForumId, tmpTopicId, tmpReplyId, ForumModuleId, ForumTabId, string.Empty);
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                        if (tmpForumId > 0 & tmpTopicId > 0 && tmpReplyId == 0)
                        {
                            TopicsController tc = new TopicsController();
                            TopicInfo        ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId);
                            if (ti != null)
                            {
                                auth = ti.Author;
                            }
                            tc.Topics_Delete(PortalId, ModuleId, tmpForumId, tmpTopicId, delAction);
                        }
                        else if (tmpForumId > 0 & tmpTopicId > 0 & tmpReplyId > 0)
                        {
                            ReplyController rc = new ReplyController();
                            ReplyInfo       ri = rc.Reply_Get(PortalId, ForumModuleId, tmpTopicId, tmpReplyId);
                            if (ri != null)
                            {
                                auth = ri.Author;
                            }
                            rc.Reply_Delete(PortalId, tmpForumId, tmpTopicId, tmpReplyId, delAction);
                        }
                    }
                    break;
                }

                case "modreject":
                {
                    int tmpForumId  = 0;
                    int tmpTopicId  = 0;
                    int tmpReplyId  = 0;
                    int tmpAuthorId = 0;
                    tmpForumId  = Convert.ToInt32(e.Parameters[1]);
                    tmpTopicId  = Convert.ToInt32(e.Parameters[2]);
                    tmpReplyId  = Convert.ToInt32(e.Parameters[3]);
                    tmpAuthorId = Convert.ToInt32(e.Parameters[4]);
                    ModController mc = new ModController();
                    mc.Mod_Reject(PortalId, ForumModuleId, UserId, tmpForumId, tmpTopicId, tmpReplyId);
                    if (fi.ModRejectTemplateId > 0 & tmpAuthorId > 0)
                    {
                        DotNetNuke.Entities.Users.UserController uc = new DotNetNuke.Entities.Users.UserController();
                        DotNetNuke.Entities.Users.UserInfo       ui = uc.GetUser(PortalId, tmpAuthorId);
                        if (ui != null)
                        {
                            Author au = new Author();
                            au.AuthorId    = tmpAuthorId;
                            au.DisplayName = ui.DisplayName;
                            au.Email       = ui.Email;
                            au.FirstName   = ui.FirstName;
                            au.LastName    = ui.LastName;
                            au.Username    = ui.Username;
                            Email.SendEmail(fi.ModRejectTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, au);
                        }
                    }

                    break;
                }

                case "modappr":
                {
                    int tmpForumId = -1;
                    int tmpTopicId = -1;
                    int tmpReplyId = -1;
                    tmpForumId = Convert.ToInt32(e.Parameters[1]);
                    tmpTopicId = Convert.ToInt32(e.Parameters[2]);
                    tmpReplyId = Convert.ToInt32(e.Parameters[3]);
                    string sSubject = string.Empty;
                    string sBody    = string.Empty;
                    if (tmpForumId > 0 & tmpTopicId > 0 && tmpReplyId == 0)
                    {
                        TopicsController tc = new TopicsController();
                        TopicInfo        ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId, tmpForumId, -1, false);
                        if (ti != null)
                        {
                            sSubject      = ti.Content.Subject;
                            sBody         = ti.Content.Body;
                            ti.IsApproved = true;
                            tc.TopicSave(PortalId, ti);
                            tc.Topics_SaveToForum(tmpForumId, tmpTopicId, PortalId, ModuleId);
                            //TODO: Add Audit log for who approved topic
                            if (fi.ModApproveTemplateId > 0 & ti.Author.AuthorId > 0)
                            {
                                Email.SendEmail(fi.ModApproveTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, ti.Author);
                            }

                            Subscriptions.SendSubscriptions(PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, 0, ti.Content.AuthorId);

                            try
                            {
                                ControlUtils ctlUtils = new ControlUtils();
                                string       sUrl     = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, -1, fi.SocialGroupId); // Utilities.NavigateUrl(ForumTabId, "", ParamKeys.ViewType & "=" & Views.Topic & "&" & ParamKeys.ForumId & "=" & ForumId, ParamKeys.TopicId & "=" & TopicId)
                                if (sUrl.Contains("~/") || Request.QueryString["asg"] != null)
                                {
                                    sUrl = Utilities.NavigateUrl(ForumTabId, "", ParamKeys.TopicId + "=" + TopicId);
                                }
                                Social amas = new Social();
                                if (Request.QueryString["asg"] == null & !(string.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey)) && fi.ActiveSocialEnabled)
                                {
                                    amas.AddTopicToJournal(PortalId, ForumModuleId, ForumId, ti.TopicId, ti.Author.AuthorId, sUrl, sSubject, ti.Content.Summary, sBody, fi.ActiveSocialSecurityOption, fi.Security.Read, SocialGroupId);
                                }
                                else
                                {
                                    amas.AddForumItemToJournal(PortalId, ForumModuleId, ti.Author.AuthorId, "forumtopic", sUrl, sSubject, sBody);
                                }
                            }
                            catch (Exception ex)
                            {
                                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                            }
                        }
                    }
                    else if (tmpForumId > 0 & tmpTopicId > 0 & tmpReplyId > 0)
                    {
                        ReplyController rc = new ReplyController();
                        ReplyInfo       ri = rc.Reply_Get(PortalId, ForumModuleId, tmpTopicId, tmpReplyId);
                        if (ri != null)
                        {
                            ri.IsApproved = true;
                            sSubject      = ri.Content.Subject;
                            sBody         = ri.Content.Body;
                            rc.Reply_Save(PortalId, ri);
                            TopicsController tc = new TopicsController();
                            tc.Topics_SaveToForum(tmpForumId, tmpTopicId, PortalId, ModuleId, tmpReplyId);
                            TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId, tmpForumId, -1, false);
                            //TODO: Add Audit log for who approved topic
                            if (fi.ModApproveTemplateId > 0 & ri.Author.AuthorId > 0)
                            {
                                Email.SendEmail(fi.ModApproveTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, ri.Author);
                            }

                            Subscriptions.SendSubscriptions(PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, ri.Content.AuthorId);

                            try
                            {
                                ControlUtils ctlUtils = new ControlUtils();
                                string       fullURL  = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, -1, fi.SocialGroupId);
                                if (fullURL.Contains("~/") || Request.QueryString["asg"] != null)
                                {
                                    fullURL = Utilities.NavigateUrl(ForumTabId, "", new string[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + tmpReplyId });
                                }
                                Social amas = new Social();
                                if (Request.QueryString["asg"] == null & !(string.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey)) && fi.ActiveSocialEnabled && !fi.ActiveSocialTopicsOnly)
                                {
                                    amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, ri.TopicId, ri.ReplyId, ri.Author.AuthorId, fullURL, ri.Content.Subject, string.Empty, sBody, fi.ActiveSocialSecurityOption, fi.Security.Read, fi.SocialGroupId);
                                }
                                else
                                {
                                    amas.AddForumItemToJournal(PortalId, ForumModuleId, ri.Author.AuthorId, "forumreply", fullURL, sSubject, sBody);
                                }
                            }
                            catch (Exception ex)
                            {
                                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                            }
                        }
                    }


                    break;
                }
                }
                string cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
                DataCache.CacheClearPrefix(cachekey);
            }
            BuildModList();
            litTopics.RenderControl(e.Output);
        }
 private void agRanks_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e)
 {
     agRanks.Datasource = DataProvider.Instance().Ranks_List(PortalId, ModuleId);
     agRanks.Refresh(e.Output);
 }
 private void cbSubscribe_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e)
 {
     ToggleSubscribe();
     chkSubscribe.RenderControl(e.Output);
 }
Esempio n. 10
0
        private void cbAttach_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e)
        {
            string attachIds = e.Parameters[1].ToString();

            switch (e.Parameters[0].ToLowerInvariant())
            {
            case "delcont":
            {
                if (SimulateIsNumeric.IsNumeric(e.Parameters[2]))
                {
                    int aid = Convert.ToInt32(e.Parameters[2]);
                    int uid = -1;
                    if (SimulateIsNumeric.IsNumeric(e.Parameters[3]))
                    {
                        uid = Convert.ToInt32(e.Parameters[3]);
                    }
                    if ((uid == this.UserId && !(this.UserId == -1)) | Permissions.HasPerm(ForumInfo.Security.ModDelete, ForumUser.UserRoles) || UserInfo.IsSuperUser)
                    {
                        Data.AttachController adb = new Data.AttachController();
                        adb.Attach_Delete(aid, ContentId);
                        //ac.Attach_Delete(aid, -1, uid)
                    }
                }
                break;
            }

            case "thumb":
            {
                if (SimulateIsNumeric.IsNumeric(e.Parameters[2]))
                {
                    int aid = Convert.ToInt32(e.Parameters[2]);
                    Data.AttachController ac = new Data.AttachController();
                    int uid = -1;
                    if (SimulateIsNumeric.IsNumeric(e.Parameters[3]))
                    {
                        uid = Convert.ToInt32(e.Parameters[3]);
                    }
                    AttachInfo ai = ac.Attach_Get(aid, -1, uid, false);
                    if (ai != null)
                    {
                        int w = Convert.ToInt32(e.Parameters[4]);
                        int h = Convert.ToInt32(e.Parameters[5]);
                        System.IO.MemoryStream imgStream = new System.IO.MemoryStream();
                        string fpath       = string.Empty;
                        int    fileSize    = 0;
                        string tmpFilename = string.Empty;
                        if (ai.FileData != null)
                        {
                            byte[] bindata = null;
                            bindata = (byte[])ai.FileData;
                            System.IO.MemoryStream memStream = new System.IO.MemoryStream(bindata);
                            imgStream   = (System.IO.MemoryStream)(Images.CreateImageForDB(memStream, h, w));
                            fileSize    = Convert.ToInt32(imgStream.Length);
                            tmpFilename = "thumb_" + ai.Filename;
                        }
                        else
                        {
                            fpath = Server.MapPath(PortalSettings.HomeDirectory + "activeforums_Attach/");
                            //fpath &= "thumb_" & ai.Filename
                            tmpFilename = "thumb_" + ai.Filename;
                            string sFullFile = fpath + tmpFilename;
                            int    i         = 0;

                            while (File.Exists(sFullFile))
                            {
                                i          += 1;
                                tmpFilename = i.ToString().PadLeft(3, '0') + "_thumb_" + ai.Filename;
                                sFullFile   = fpath + tmpFilename;
                            }
                            File.Copy(fpath + ai.Filename, sFullFile);
                            Images.CreateImage(sFullFile, h, w);
                            fileSize = (int)new FileInfo(sFullFile).Length;
                        }
                        AttachInfo aiThumb = new AttachInfo();
                        aiThumb.ContentId   = -1;
                        aiThumb.UserID      = ai.UserID;
                        aiThumb.Filename    = tmpFilename;
                        aiThumb.ContentType = "image/x-png";
                        aiThumb.FileSize    = fileSize;
                        if (ForumInfo.AttachStore == AttachStores.DATABASE)
                        {
                            aiThumb.FileData = imgStream.ToArray();
                            //File.Delete(fpath & "thumb_" & ai.Filename)
                        }
                        aiThumb.ParentAttachId = aid;
                        int thumbId = ac.Attach_Save(aiThumb);
                        attachIds += thumbId.ToString() + ";";
                        BindMyFiles();
                        if (Convert.ToBoolean(e.Parameters[4]))
                        {
                            string strHost = DotNetNuke.Common.Globals.AddHTTP(DotNetNuke.Common.Globals.GetDomainName(Request)) + "/";
                            string s       = "<script type=\"text/javascript\">";
                            string sInsert = string.Empty;
                            if (ForumInfo.AllowHTML && ForumInfo.EditorType != EditorTypes.TEXTBOX)
                            {
                                sInsert = "<a href=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + PortalId + "&moduleid=" + ModuleId + "&attachid=" + aid + "\" target=\"_blank\"><img src=" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + PortalId + "&moduleid=" + ModuleId + "&attachid=" + thumbId + " border=0 /></a>";
                            }
                            else
                            {
                                sInsert = "[THUMBNAIL:" + thumbId.ToString() + ":" + aid + "]";
                            }

                            s += "amaf_insertHTML('" + sInsert + "');";
                            s += "</script>";
                            LiteralControl litScript = new LiteralControl();
                            litScript.Text = s;
                            plhAttach.Controls.Add(litScript);
                        }
                    }
                }
                break;
            }

            case "inline":
            {
                if (SimulateIsNumeric.IsNumeric(e.Parameters[2]))
                {
                    int aid = Convert.ToInt32(e.Parameters[2]);
                    Data.AttachController ac = new Data.AttachController();
                    int uid = -1;
                    if (SimulateIsNumeric.IsNumeric(e.Parameters[3]))
                    {
                        uid = Convert.ToInt32(e.Parameters[3]);
                    }
                    AttachInfo ai = ac.Attach_Get(aid, -1, uid, false);
                    if (ai != null)
                    {
                        int opt = Convert.ToInt32(e.Parameters[4]);
                        if (opt == 0)
                        {
                            ai.DisplayInline = true;
                            ai.AllowDownload = false;
                        }
                        else
                        {
                            if (ai.AllowDownload)
                            {
                                ai.DisplayInline = true;
                                ai.AllowDownload = false;
                            }
                            else
                            {
                                ai.DisplayInline = false;
                                ai.AllowDownload = true;
                            }
                        }


                        ac.Attach_Save(ai);
                    }
                }
                break;
            }
            }

            BindAttach(attachIds);
            System.IO.StringWriter stringWriter = new System.IO.StringWriter();
            HtmlTextWriter         htmlWriter   = new HtmlTextWriter(stringWriter);

            plhAttach.RenderControl(htmlWriter);
            string html = stringWriter.GetStringBuilder().ToString();

            html = Utilities.LocalizeControl(html);
            LiteralControl lit = new LiteralControl();

            lit.Text = html;
            lit.RenderControl(e.Output);
        }