コード例 #1
0
 private void LoadSettings()
 {
     siteSettings = CacheHelper.GetCurrentSiteSettings();
     zoneId       = WebUtils.ParseInt32FromQueryString("zoneid", zoneId);
     currentUser  = SiteUtils.GetCurrentSiteUser();
     timeOffset   = SiteUtils.GetUserTimeOffset();
     timeZone     = SiteUtils.GetUserTimeZone();
 }
コード例 #2
0
        private void LoadSettings()
        {
            siteSettings = CacheHelper.GetCurrentSiteSettings();
            siteId       = siteSettings.SiteId;
            currentUser  = SiteUtils.GetCurrentSiteUser();

            SetupCommentSystem();
        }
コード例 #3
0
 private void LoadParam()
 {
     current = SiteUtils.GetCurrentSiteUser();
     author  = KLAuthor.GetKLAuthorByUserID(current.UserId);
     GeneralVariables.NameAuthor = current.Name;
     GeneralVariables.Level      = author.LevelAuthor;
     hduserid.Value = current.UserId.ToString();
 }
コード例 #4
0
ファイル: Edit.aspx.cs プロジェクト: zahedbri/mojoportal
        private void btnUpdateFile_Click(object sender, EventArgs e)
        {
            SiteUser siteUser = SiteUtils.GetCurrentSiteUser();

            if (siteUser == null)
            {
                return;
            }

            SharedFile file = new SharedFile(moduleId, itemId);

            file.ContentChanged += new ContentChangedEventHandler(sharedFile_ContentChanged);

            if ((file.ItemId > 0) && (file.ModuleId == moduleId))
            {
                file.FriendlyName = txtFriendlyName.Text;
                file.Description  = edDescription.Text;
                file.FolderId     = int.Parse(ddFolders.SelectedValue);

                if (file.FolderId > -1)
                {
                    SharedFileFolder folder = new SharedFileFolder(moduleId, file.FolderId);
                    file.FolderGuid = folder.FolderGuid;
                }

                if (file.ModuleGuid == Guid.Empty)
                {
                    Module m = new Module(moduleId);
                    file.ModuleGuid = m.ModuleGuid;
                }

                file.UploadUserId = siteUser.UserId;
                // really last mod date
                file.UploadDate = DateTime.UtcNow;

                List <ListItem> selectedRoles = cblRolesThatCanViewFile.Items.Cast <ListItem>()
                                                .Where(li => li.Selected)
                                                .ToList();

                string viewRoles = String.Join(";", selectedRoles.Select(x => x.Value.ToString()).ToArray());

                file.ViewRoles = viewRoles;
                file.Save();
            }

            CurrentPage.UpdateLastModifiedTime();
            CacheHelper.ClearModuleCache(moduleId);
            SiteUtils.QueueIndexing();

            if (hdnReturnUrl.Value.Length > 0)
            {
                WebUtils.SetupRedirect(this, hdnReturnUrl.Value);

                return;
            }

            WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
        }
コード例 #5
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            if (uploader.HasFile)
            {
                SiteUser siteUser = SiteUtils.GetCurrentSiteUser();
                if (siteUser == null)
                {
                    return;
                }

                SharedFile sharedFile = new SharedFile(this.moduleId, this.itemId);
                sharedFile.ContentChanged += new ContentChangedEventHandler(sharedFile_ContentChanged);

                if (config.EnableVersioning)
                {
                    bool historyCreated = SharedFilesHelper.CreateHistory(sharedFile, fileSystem, virtualSourcePath, virtualHistoryPath);
                    if (historyCreated)
                    {
                        sharedFile.ServerFileName = System.Guid.NewGuid().ToString() + ".config";
                    }
                }


                sharedFile.ModuleId = this.moduleId;
                if (sharedFile.ModuleGuid == Guid.Empty)
                {
                    Module m = GetModule(moduleId, SharedFile.FeatureGuid);
                    sharedFile.ModuleGuid = m.ModuleGuid;
                }

                string fileName = Path.GetFileName(uploader.FileName);

                sharedFile.OriginalFileName = fileName;
                sharedFile.FriendlyName     = fileName;
                sharedFile.SizeInKB         = (int)(uploader.FileBytes.Length / 1024);
                sharedFile.UploadUserId     = siteUser.UserId;
                sharedFile.UploadDate       = DateTime.UtcNow;

                if (sharedFile.Save())
                {
                    string destPath = virtualSourcePath + sharedFile.ServerFileName;

                    using (Stream s = uploader.FileContent)
                    {
                        //fileSystem.SaveFile(destPath, file1.FileContent, file1.ContentType, true);
                        fileSystem.SaveFile(destPath, s, IOHelper.GetMimeType(Path.GetExtension(sharedFile.FriendlyName).ToLower()), true);
                    }
                }



                CurrentPage.UpdateLastModifiedTime();
                CacheHelper.ClearModuleCache(moduleId);
                SiteUtils.QueueIndexing();
            }

            WebUtils.SetupRedirect(this, Request.RawUrl);
        }
コード例 #6
0
        private void LoadSettings()
        {
            pageId      = WebUtils.ParseInt32FromQueryString("pageid", pageId);
            moduleId    = WebUtils.ParseInt32FromQueryString("mid", moduleId);
            itemId      = WebUtils.ParseInt32FromQueryString("ItemID", itemId);
            commentGuid = WebUtils.ParseGuidFromQueryString("c", commentGuid);
            if (commentGuid == Guid.Empty)
            {
                return;
            }

            blog              = new Blog(itemId);
            module            = GetModule(moduleId, Blog.FeatureGuid);
            commentRepository = new CommentRepository();

            if (blog.ModuleId != module.ModuleId)
            {
                blog   = null;
                module = null;
                return;
            }

            comment = commentRepository.Fetch(commentGuid);
            if ((comment.ContentGuid != blog.BlogGuid) || (comment.ModuleGuid != module.ModuleGuid))
            {
                blog   = null;
                module = null;
                return;
            }

            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);

            config = new BlogConfiguration(moduleSettings);

            currentUser = SiteUtils.GetCurrentSiteUser();

            userCanEdit = UserCanEditComment();

            commentEditor.SiteGuid       = CurrentSite.SiteGuid;
            commentEditor.SiteId         = CurrentSite.SiteId;
            commentEditor.SiteRoot       = SiteRoot;
            commentEditor.CommentsClosed = false;
            //commentEditor.CommentUrl = Request.RawUrl;
            commentEditor.ContentGuid = blog.BlogGuid;
            //commentEditor.DefaultCommentTitle = defaultCommentTitle;
            commentEditor.FeatureGuid = Blog.FeatureGuid;
            commentEditor.ModuleGuid  = module.ModuleGuid;
            //commentEditor.NotificationAddresses = notificationAddresses;
            //commentEditor.NotificationTemplateName = notificationTemplateName;
            commentEditor.RequireCaptcha  = false;
            commentEditor.UserCanModerate = userCanEdit;
            //commentEditor.Visible = !commentsClosed;
            commentEditor.CurrentUser    = currentUser;
            commentEditor.UserComment    = comment;
            commentEditor.ShowRememberMe = false;
            //commentEditor.IncludeIpAddressInNotification = includeIpAddressInNotification;
            //commentEditor.ContainerControl = this;
        }
コード例 #7
0
ファイル: ReviewEdit.aspx.cs プロジェクト: sang-nm/mphc
        private int Create()
        {
            if (!Page.IsValid)
            {
                return(-1);
            }
            if (!reply)
            {
                return(-1);
            }

            if (!canApprove)
            {
                return(-1);
            }

            try
            {
                ProductComment cm = new ProductComment();
                cm.ProductId     = comment.ProductId;
                cm.ParentId      = comment.CommentId;
                cm.FullName      = txtFullName.Text.Trim();
                cm.Email         = txtEmail.Text.Trim();
                cm.Title         = txtCommentTitle.Text.Trim();
                cm.Status        = 1;
                cm.ContentText   = txtComment.Text;
                cm.Rating        = Convert.ToInt32(ratRating.Value);
                cm.CreatedFromIP = SiteUtils.GetIP4Address();

                SiteUser siteUser = SiteUtils.GetCurrentSiteUser();
                if (siteUser != null)
                {
                    cm.UserId = siteUser.UserId;
                }

                cm.Status      = 1;
                cm.IsModerator = true;

                if (comment.Status != 1)
                {
                    comment.Status = 1;
                    comment.Save();
                }

                cm.Save();

                LogActivity.Write("Reply comment", comment.FullName);
                message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "InsertSuccessMessage");

                return(cm.CommentId);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }

            return(-1);
        }
コード例 #8
0
        private void BindGrid()
        {
            bool isAdmin = ((WebUser.IsInRole("iQuranManagers")) || (WebUser.IsInRole("iQuranContentsAdmins")) || (WebUser.IsAdmin));
            // Get the Current Loged on UserID
            SiteUser siteUser = SiteUtils.GetCurrentSiteUser();
            int      userID   = siteUser.UserId;

            List <Quran> dataList = new List <Quran>();


            //0: all ,    1.active  ,     2.notactive  ,


            if (this.BindByWhat == "all")
            {
                dataList = Quran.GetPage_iQuran_All(false, siteSettings.SiteId, isAdmin, pageNumber, pageSize, out totalPages);
            }

            //Search For Title
            if (this.BindByWhat == "title")
            {
                dataList = Quran.GetPage_iQuran_ByTitle(false, siteSettings.SiteId, isAdmin, this.searchTitle, pageNumber, pageSize, out totalPages);
            }

            if ((this.BindByWhat == "active") || (this.BindByWhat == "notactive"))
            {
                dataList = Quran.GetPage_iQuran_ByActive(false, siteSettings.SiteId, searchIsActive, pageNumber, pageSize, out totalPages);
            }


            string pageUrl = string.Empty;

            pageUrl = SiteRoot
                      + "/Admin/AccessQuran/iQuran/iQuranManager.aspx?"
                      + "sort=" + this.sort
                      + "&amp;search=" + this.search
                      + "&amp;searchtitle=" + Server.UrlEncode(this.searchTitle)
                      + "&amp;pagenumber={0}";

            amsPager.PageURLFormat = pageUrl;
            amsPager.ShowFirstLast = true;
            amsPager.CurrentIndex  = pageNumber;
            amsPager.PageSize      = pageSize;
            amsPager.PageCount     = totalPages;
            amsPager.Visible       = (totalPages > 1);

            iQGrid.DataSource = dataList;
            iQGrid.PageIndex  = pageNumber;
            iQGrid.PageSize   = pageSize;
            iQGrid.DataBind();

            if (iQGrid.Rows.Count == 0)
            {
                lblmessage.Visible = true;
                divMsg.Visible     = true;
                lblmessage.Text    = Resources.iQuranMessagesResources.NoDataYet;
            }
        }
コード例 #9
0
        void iQVGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug(this.PageTitle + " fired event iQVGrid_RowCommand");
            }

            int    iverseID  = int.Parse(e.CommandArgument.ToString());
            int    siteid    = siteSettings.SiteId;
            string dleteDate = String.Format(DateTime.Now.ToString(), "mm dd yyyy");

            currentUser = SiteUtils.GetCurrentSiteUser();
            int        suraid = -1;
            QuranVerse iverse = null;

            // QuranVerseTranslation iverseTransl = null;

            if (this.hdnQLang.Value == "ar")
            {
                iverse = new QuranVerse(siteid, int.Parse(hdnQuranID.Value), iverseID, false);
            }
            else
            {
                iverse = new QuranVerse(siteid, int.Parse(hdnQuranID.Value), iverseID, true);
            }
            //iverseTransl = new QuranVerseTranslation(siteid, int.Parse(hdnQuranID.Value), iverseID);



            switch (e.CommandName)
            {
            case "delete":
            default:
                if (this.hdnQLang.Value == "ar")
                {
                    QuranVerse.DeleteVerse(siteid, iverse.QuranID, iverse.SuraID, iverseID);
                    suraid = iverse.SuraID;
                }
                else
                {
                    QuranVerseTranslation iverseTransl = new QuranVerseTranslation(siteid, int.Parse(hdnQuranID.Value), iverseID);
                    QuranVerse.DeleteVerse_Translation(siteid, iverseTransl.QuranID, iverseTransl.SuraID, iverseTransl.VerseID);
                    suraid = iverseTransl.SuraID;
                }

                //iQVGrid.EditIndex = +1;
                //log it:
                log.Info("user " + currentUser.Name + " deleted Verse Version : " + iverse.QuranVerseTxt + " at:  " + dleteDate);
                //BindGrid();
                //lblmessage.Text = iQuranMessagesResources.DeletedMsg + "<br />";
                //lblmessage.Visible = true;
                //divMsg.Visible = true;
                hdnSuraID.Value = suraid.ToString();
                SetRedirectString(true, true, "ok");
                break;
            }
        }
コード例 #10
0
 protected void imgBtnLikes_Click(object sender, ImageClickEventArgs e)
 {
     if (Request.QueryString != null && Request.QueryString["mediaId"] != null)
     {
         string mediaId = (string)Request.QueryString["mediaId"];
         (new KalturaModule()).SetLikeforKalturaMedia(mediaId, SiteUtils.GetCurrentSiteUser().UserId);
     }
     GetLikesforVideo();
 }
コード例 #11
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            Forum forum = new Forum(itemId);

            if ((forum.ItemId > -1) && (forum.ModuleId != moduleId))
            {
                SiteUtils.RedirectToAccessDeniedPage(this);
                return;
            }

            //SiteUser siteUser = new SiteUser(siteSettings, Context.User.Identity.Name);
            SiteUser siteUser = SiteUtils.GetCurrentSiteUser();

            if (siteUser != null)
            {
                forum.CreatedByUserId = siteUser.UserId;
            }

            forum.ModuleId    = moduleId;
            forum.Description = edContent.Text;
            forum.Title       = this.txtTitle.Text;
            forum.IsActive    = this.chkIsActive.Checked;
            //forum.AllowAnonymousPosts = this.chkAllowAnonymousPosts.Checked;
            forum.IsModerated    = this.chkIsModerated.Checked;
            forum.SortOrder      = int.Parse(this.txtSortOrder.Text);
            forum.PostsPerPage   = int.Parse(this.txtPostsPerPage.Text);
            forum.ThreadsPerPage = int.Parse(this.txtThreadsPerPage.Text);

            allowedPostRolesSetting = allowedPostRoles as AllowedRolesSetting;
            forum.RolesThatCanPost  = allowedPostRolesSetting.GetValue();

            moderatorRolesSetting      = moderatorRoles as AllowedRolesSetting;
            forum.RolesThatCanModerate = moderatorRolesSetting.GetValue();

            forum.RequireModForNotify      = chkRequireModForNotify.Checked;
            forum.AllowTrustedDirectNotify = chkAllowTrustedDirectNotify.Checked;
            forum.ModeratorNotifyEmail     = txtModeratorNotifyEmail.Text;
            forum.IncludeInGoogleMap       = chkIncludeInGoogleMap.Checked;
            forum.AddNoIndexMeta           = chkAddNoIndexMeta.Checked;
            forum.Closed  = chkClosed.Checked;
            forum.Visible = chkVisible.Checked;

            if (forum.Save())
            {
                CurrentPage.UpdateLastModifiedTime();
                //CacheHelper.TouchCacheDependencyFile(cacheDependencyKey);
                CacheHelper.ClearModuleCache(forum.ModuleId);

                if (hdnReturnUrl.Value.Length > 0)
                {
                    WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                    return;
                }

                WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
            }
        }
コード例 #12
0
        private void grdTaxRate_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridView grid     = (GridView)sender;
            Guid     guid     = new Guid(grid.DataKeys[e.RowIndex].Value.ToString());
            SiteUser siteUser = SiteUtils.GetCurrentSiteUser();

            if (ddGeoZones.SelectedIndex > -1)
            {
                geoZoneGuid = new Guid(ddGeoZones.SelectedValue);
            }

            TextBox      txtDescription = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtDescription");
            DropDownList ddTaxClass     = (DropDownList)grid.Rows[e.RowIndex].Cells[1].FindControl("ddTaxClass");
            TextBox      txtPriority    = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtPriority");
            TextBox      txtRate        = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtRate");

            TaxRate taxRate;

            if (guid != Guid.Empty)
            {
                taxRate = new TaxRate(guid);
            }
            else
            {
                taxRate           = new TaxRate(siteSettings.SiteGuid, geoZoneGuid);
                taxRate.Created   = DateTime.UtcNow;
                taxRate.CreatedBy = siteUser.UserGuid;
            }

            taxRate.Description = txtDescription.Text;
            taxRate.GeoZoneGuid = geoZoneGuid;
            Guid taxClassGuid = new Guid(ddTaxClass.SelectedValue);

            taxRate.TaxClassGuid = taxClassGuid;

            int priority;

            if (!int.TryParse(txtPriority.Text, out priority))
            {
                priority = 1;
            }
            taxRate.Priority = priority;

            decimal rate;

            if (!decimal.TryParse(txtRate.Text, out rate))
            {
                rate = 0;
            }

            taxRate.Rate         = rate;
            taxRate.LastModified = DateTime.UtcNow;
            taxRate.ModifiedBy   = siteUser.UserGuid;
            taxRate.Save();

            WebUtils.SetupRedirect(this, GetRefreshUrl());
        }
コード例 #13
0
 protected void LoadSettings()
 {
     siteSettings = CacheHelper.GetCurrentSiteSettings();
     zoneId       = WebUtils.ParseInt32FromQueryString("zoneid", zoneId);
     currentUser  = SiteUtils.GetCurrentSiteUser();
     timeOffset   = SiteUtils.GetUserTimeOffset();
     timeZone     = SiteUtils.GetUserTimeZone();
     pageNumber   = WebUtils.ParseInt32FromQueryString("pagenumber", pageNumber);
 }
コード例 #14
0
        private string GetVirtualPath()
        {
            var siteSettings = CacheHelper.GetCurrentSiteSettings();

            if (siteSettings == null)
            {
                log.Error("Cannot load file system because Site Settings could not be loaded.");
                throw new ArgumentNullException("could not load SiteSettings");
            }

            int siteId = siteSettings.SiteId;

            if (WebConfigSettings.UseRelatedSiteMode && WebConfigSettings.UseSameContentFolderForRelatedSiteMode)
            {
                siteId = WebConfigSettings.RelatedSiteID;
            }

            var virtualPath = $"~/Data/Sites/{siteId.ToInvariantString()}/media/";

            if (WebUser.IsAdminOrContentAdmin || SiteUtils.UserIsSiteEditor())
            {
                if (WebConfigSettings.ForceAdminsToUseMediaFolder)
                {
                    virtualPath = $"~/Data/Sites/{siteId.ToInvariantString()}/media/";
                }
                else
                {
                    if (siteSettings.IsServerAdminSite && WebConfigSettings.AllowAdminsToUseDataFolder && WebUser.IsAdmin)
                    {
                        virtualPath = "~/Data/";
                    }
                    else
                    {
                        virtualPath = $"~/Data/Sites/{siteId.ToInvariantString()}/";
                    }
                }
            }
            else if (WebUser.IsInRoles(siteSettings.GeneralBrowseAndUploadRoles))
            {
                virtualPath = $"~/Data/Sites/{siteId.ToInvariantString()}/media/";
            }
            else if (WebUser.IsInRoles(siteSettings.UserFilesBrowseAndUploadRoles))
            {
                var currentUser = SiteUtils.GetCurrentSiteUser();

                if (currentUser == null)
                {
                    log.Error("Cannot load file system because Site User could not be loaded.");
                    throw new ArgumentNullException("could not load current SiteUser");
                }

                virtualPath = $"~/Data/Sites/{siteId.ToInvariantString()}/userfiles/{currentUser.UserId.ToInvariantString()}/";
            }


            return(virtualPath);
        }
コード例 #15
0
        private void PopulateControls()
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<ProductList></ProductList>");
            XmlElement root = doc.DocumentElement;

            XmlHelper.AddNode(doc, root, "ModuleTitle", this.Title);
            XmlHelper.AddNode(doc, root, "ZoneTitle", CurrentZone.Name);
            XmlHelper.AddNode(doc, root, "ViewMore", ProductResources.ViewMoreLabel);

            if (ModuleConfiguration.ResourceFileDef.Length > 0 && ModuleConfiguration.ResourceKeyDef.Length > 0)
            {
                List <string> lstResourceKeys = ModuleConfiguration.ResourceKeyDef.SplitOnCharAndTrim(';');

                foreach (string item in lstResourceKeys)
                {
                    XmlHelper.AddNode(doc, root, item, ResourceHelper.GetResourceString(ModuleConfiguration.ResourceFileDef, item));
                }
            }

            CmsBasePage basePage      = Page as CmsBasePage;
            bool        userCanUpdate = ProductPermission.CanUpdate;
            SiteUser    currentUser   = SiteUtils.GetCurrentSiteUser();

            List <Product> lstProducts = new List <Product>();

            if (ProductConfiguration.RecentlyViewedProductsEnabled && config.Position == 0)
            {
                lstProducts = ProductHelper.GetRecentlyViewedProducts(config.MaxProductsToGet);
            }
            else if (config.ZoneId > -1)
            {
                int zoneId = config.ZoneId;
                if (zoneId == 0)
                {
                    zoneId = CurrentZone.ZoneId;
                }

                string zoneRangeIds = ProductHelper.GetRangeZoneIdsToSemiColonSeparatedString(siteSettings.SiteId, zoneId);
                lstProducts = Product.GetPageBySearch(1, config.MaxProductsToGet, siteSettings.SiteId, zoneRangeIds, 1, WorkingCulture.LanguageId, -1, -1, null, null, config.Position);
            }
            else
            {
                lstProducts = Product.GetPage(SiteId, -1, WorkingCulture.LanguageId, config.Position, 1, config.MaxProductsToGet);
            }

            foreach (Product product in lstProducts)
            {
                XmlElement productXml = doc.CreateElement("Product");
                root.AppendChild(productXml);

                ProductHelper.BuildProductDataXml(doc, productXml, product, timeZone, timeOffset, ProductHelper.BuildEditLink(product, basePage, userCanUpdate, currentUser));
            }

            XmlHelper.XMLTransform(xmlTransformer, SiteUtils.GetXsltBasePath("product", ModuleConfiguration.XsltFileName), doc);
        }
コード例 #16
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            Page.Validate("eventcalendaredit");
            if (Page.IsValid)
            {
                int  userId   = -1;
                Guid userGuid = Guid.Empty;
                if (Request.IsAuthenticated)
                {
                    //SiteUser siteUser = new SiteUser(siteSettings, Context.User.Identity.Name);
                    SiteUser siteUser = SiteUtils.GetCurrentSiteUser();
                    userId   = siteUser.UserId;
                    userGuid = siteUser.UserGuid;
                }
                CalendarEvent calEvent = new CalendarEvent(itemId);

                if ((itemId > -1) && (calEvent.ModuleId != moduleId))
                {
                    SiteUtils.RedirectToAccessDeniedPage(this);
                    return;
                }

                calEvent.ContentChanged += new ContentChangedEventHandler(calendarEvent_ContentChanged);

                Module m = new Module(this.moduleId);
                calEvent.ModuleId        = m.ModuleId;
                calEvent.ModuleGuid      = m.ModuleGuid;
                calEvent.UserId          = userId;
                calEvent.UserGuid        = userGuid;
                calEvent.LastModUserGuid = userGuid;
                calEvent.Title           = this.txtTitle.Text;
                calEvent.Description     = edContent.Text;
                calEvent.EventDate       = DateTime.Parse(this.dpEventDate.Text);
                calEvent.StartTime       = DateTime.Parse(this.ddStartTime.SelectedValue);
                calEvent.EndTime         = DateTime.Parse(this.ddEndTime.SelectedValue);
                calEvent.Location        = txtLocation.Text;



                if (calEvent.Save())
                {
                    CurrentPage.UpdateLastModifiedTime();
                    //CacheHelper.TouchCacheDependencyFile(cacheDependencyKey);
                    CacheHelper.ClearModuleCache(moduleId);

                    SiteUtils.QueueIndexing();

                    if (hdnReturnUrl.Value.Length > 0)
                    {
                        WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                        return;
                    }

                    WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                }
            }
        }
コード例 #17
0
        protected virtual void LoadSettings()
        {
            siteRoot     = SiteUtils.GetNavigationSiteRoot();
            siteSettings = CacheHelper.GetCurrentSiteSettings();
            siteID       = siteSettings.SiteId;
            currentUser  = SiteUtils.GetCurrentSiteUser();

            var moduleSettings = ModuleSettings.GetModuleSettings(moduleID);

            if (moduleSettings != null)
            {
                bigConfig = new BIGConfig(moduleSettings);
            }

            FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider];

            if (p == null)
            {
                log.Error(string.Format(BetterImageGalleryResources.FileSystemProviderNotLoaded, WebConfigSettings.FileSystemProvider));
            }

            fileSystem = p.GetFileSystem();

            if (fileSystem == null)
            {
                log.Error(string.Format(BetterImageGalleryResources.FileSystemNotLoadedFromProvider, WebConfigSettings.FileSystemProvider));
            }

            // Media Folder
            mediaRootPath = fileSystem.VirtualRoot;
            // Gallery Module Folder
            galleryRootPath = mediaRootPath + "BetterImageGallery/";
            // Gallery Folder
            galleryPath = galleryRootPath + bigConfig.FolderPath.TrimEnd('/');

            // Creates the Gallery Module Folder if it doesn't exist
            if (!fileSystem.FolderExists(galleryRootPath))
            {
                fileSystem.CreateFolder(galleryRootPath);
            }

            // Creates the Gallery Module Folder if it doesn't exist
            if (!fileSystem.FolderExists(galleryPath))
            {
                Error = new BIGErrorResult
                {
                    Type    = "FolderNotFound",
                    Message = BetterImageGalleryResources.FolderNotFound
                };
            }

            // Creates module thumbnail cache folder if it doesn't exist
            if (!fileSystem.FolderExists(moduleThumbnailCachePath))
            {
                fileSystem.CreateFolder(moduleThumbnailCachePath);
            }
        }
コード例 #18
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            // as long as javascript is available this code should never execute
            // because the standard file input ir replaced by javascript and the file upload happens
            // at the service url /SharedFiles/upload.ashx
            // this is fallback implementation

            if (!fileSystem.FolderExists(fileVirtualBasePath))
            {
                fileSystem.CreateFolder(fileVirtualBasePath);
            }

            SiteUser siteUser = SiteUtils.GetCurrentSiteUser();

            if (siteUser == null)
            {
                WebUtils.SetupRedirect(this, Request.RawUrl); return;
            }


            if (uploader.HasFile)
            {
                SharedFile sharedFile = new SharedFile();

                string fileName = Path.GetFileName(uploader.FileName);

                sharedFile.ModuleId         = ModuleId;
                sharedFile.ModuleGuid       = ModuleConfiguration.ModuleGuid;
                sharedFile.OriginalFileName = fileName;
                sharedFile.FriendlyName     = fileName;
                sharedFile.SizeInKB         = (int)(uploader.FileContent.Length / 1024);
                sharedFile.FolderId         = CurrentFolderId;

                if (CurrentFolderId > -1)
                {
                    SharedFileFolder folder = new SharedFileFolder(ModuleId, CurrentFolderId);
                    sharedFile.FolderGuid = folder.FolderGuid;
                }

                sharedFile.UploadUserId = siteUser.UserId;
                sharedFile.UserGuid     = siteUser.UserGuid;

                sharedFile.ContentChanged += new ContentChangedEventHandler(SharedFile_ContentChanged);

                if (sharedFile.Save())
                {
                    string destPath = VirtualPathUtility.Combine(fileVirtualBasePath, sharedFile.ServerFileName);

                    using (Stream s = uploader.FileContent)
                    {
                        fileSystem.SaveFile(destPath, s, IOHelper.GetMimeType(Path.GetExtension(sharedFile.FriendlyName).ToLower()), true);
                    }
                }
            }

            WebUtils.SetupRedirect(this, Request.RawUrl);
        }
コード例 #19
0
        private void LoadSettings()
        {
            currentUser    = SiteUtils.GetCurrentSiteUser();
            letterInfoGuid = WebUtils.ParseGuidFromQueryString("l", Guid.Empty);
            imageSiteRoot  = WebUtils.GetSiteRoot();



            if (letterInfoGuid == Guid.Empty)
            {
                return;
            }

            letterInfo = new LetterInfo(letterInfoGuid);

            if (letterInfo.SiteGuid != siteSettings.SiteGuid)
            {
                letterInfo     = null;
                letterInfoGuid = Guid.Empty;
            }

            letterGuid = WebUtils.ParseGuidFromQueryString("letter", Guid.Empty);

            if (letterGuid == Guid.Empty)
            {
                letter = new Letter();
            }
            else
            {
                letter = new Letter(letterGuid);

                if (letter.LetterInfoGuid != letterInfo.LetterInfoGuid)
                {
                    letterGuid = Guid.Empty;
                    letter     = null;
                }
            }


            if (letter.SendCompleteUtc > DateTime.MinValue)
            {
                btnSave.Text = Resource.SaveNewsletterAsNewDraft;


                btnSendToList.Enabled = false;
                // once a letter has been sent only admin can delete it.
                btnDelete.Enabled = WebUser.IsAdmin;
            }

            //spnAdmin.Visible = WebUser.IsAdminOrContentAdmin;
            lnkAdminMenu.Visible      = WebUser.IsAdminOrContentAdmin;
            litLinkSeparator1.Visible = lnkAdminMenu.Visible;

            AddClassToBody("administration");
            AddClassToBody("letteredit");
        }
コード例 #20
0
ファイル: PurchaseHistory.aspx.cs プロジェクト: sang-nm/mphc
        private void LoadSettings()
        {
            pageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", pageNumber);
            siteUser   = SiteUtils.GetCurrentSiteUser();

            timeOffset = SiteUtils.GetUserTimeOffset();
            timeZone   = SiteUtils.GetUserTimeZone();

            AddClassToBody("purchase-history-page");
        }
コード例 #21
0
        private void LoadSettings()
        {
            currentUser               = SiteUtils.GetCurrentSiteUser();
            letterInfoGuid            = WebUtils.ParseGuidFromQueryString("l", Guid.Empty);
            lnkAdminMenu.Visible      = WebUser.IsAdminOrContentAdmin || WebUser.IsNewsletterAdmin || SiteUtils.UserIsSiteEditor();
            litLinkSeparator1.Visible = lnkAdminMenu.Visible;

            AddClassToBody("administration");
            AddClassToBody("letterinfoedit");
        }
コード例 #22
0
        private void LoadParams()
        {
            PageId                 = WebUtils.ParseInt32FromQueryString("pageid", -1);
            moduleId               = WebUtils.ParseInt32FromQueryString("mid", -1);
            ItemId                 = WebUtils.ParseInt32FromQueryString("ItemID", -1);
            topicId                = WebUtils.ParseInt32FromQueryString("topic", -1);
            PageNumber             = WebUtils.ParseInt32FromQueryString("pagenumber", 1);
            TimeOffset             = SiteUtils.GetUserTimeOffset();
            IsAdmin                = WebUser.IsAdmin;
            isCommerceReportViewer = WebUser.IsInRoles(siteSettings.CommerceReportViewRoles);
            currencyCulture        = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);
            //allowedImageUrlRegexPattern = SiteUtils.GetRegexRelativeImageUrlPatern();

            switch (siteSettings.AvatarSystem)
            {
            case "gravatar":
                allowGravatars = true;
                disableAvatars = true;
                break;

            case "internal":
                allowGravatars = false;
                disableAvatars = false;
                break;

            case "none":
            default:
                allowGravatars = false;
                disableAvatars = true;
                break;
            }

            notificationUrl = SiteRoot + "/Groups/EditSubscriptions.aspx?mid="
                              + moduleId.ToInvariantString()
                              + "&pageid=" + PageId.ToInvariantString() + "#group" + ItemId.ToInvariantString();

            if (Request.IsAuthenticated)
            {
                if (currentUser == null)
                {
                    currentUser = SiteUtils.GetCurrentSiteUser();
                }

                if ((currentUser != null) && (ItemId > -1))
                {
                    userID = currentUser.UserId;
                    isSubscribedToGroup = Group.IsSubscribed(ItemId, currentUser.UserId);
                }

                if (!isSubscribedToGroup)
                {
                    pnlNotify.Visible = true;
                }
            }
        }
コード例 #23
0
        ///// <summary>
        ///// this is not really used since we are providing a json service url
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //void UserRating_Changed(object sender, AjaxRatingEventArgs e)
        //{
        //    if (!allowFeedback)
        //    {
        //        DoRating(Convert.ToInt32(e.Value));
        //    }
        //    else
        //    {
        //        BindRating();

        //        upRating.Update();
        //    }

        //}

        /// <summary>
        /// this is only used when comments are enabled
        /// </summary>
        /// <param name="rating"></param>
        private void DoRating(int rating)
        {
            if (ContentGuid == Guid.Empty)
            {
                return;
            }
            if (rating <= 0)
            {
                BindRating();
                upRating.Update();
                return;
            }

            SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();

            if (siteSettings == null)
            {
                return;
            }

            Guid   userGuid     = Guid.Empty;
            string emailAddress = txtEmail.Text;

            if (Request.IsAuthenticated)
            {
                SiteUser currentUser = SiteUtils.GetCurrentSiteUser();
                if (currentUser != null)
                {
                    userGuid = currentUser.UserGuid;
                    if (emailAddress.Length == 0)
                    {
                        emailAddress = currentUser.Email;
                    }
                }
            }

            ContentRating.RateContent(
                siteSettings.SiteGuid,
                ContentGuid,
                userGuid,
                rating,
                emailAddress,
                txtComments.Text,
                SiteUtils.GetIP4Address(),
                WebConfigSettings.MinutesBetweenAnonymousRatings
                );

            hdnRating.Value  = string.Empty;
            txtComments.Text = string.Empty;
            txtEmail.Text    = string.Empty;

            BindRating();

            upRating.Update();
        }
コード例 #24
0
        protected virtual void PopulateControls()
        {
            txtPosition.Text = news.Title;

            if (Request.IsAuthenticated)
            {
                SiteUser currentUser = SiteUtils.GetCurrentSiteUser();
                txtFullName.Text = currentUser.Name;
                txtEmail.Text    = currentUser.Email;
            }
        }
コード例 #25
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (workInProgress == null)
            {
                WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                return;
            }

            SiteUser currentUser = SiteUtils.GetCurrentSiteUser();

            if (currentUser == null)
            {
                WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                return;
            }
            //joe davis
            SiteUser draftSubmitter = GetDraftSubmitter(workInProgress);

            switch (workInProgress.Status)
            {
            case ContentWorkflowStatus.AwaitingApproval:
            {
                workInProgress.RejectContentChanges(
                    currentUser.UserGuid,
                    txtRejectionComments.Text);

                WorkflowHelper.SendRejectionNotification(
                    SiteUtils.GetSmtpSettings(),
                    siteSettings,
                    currentUser,
                    workInProgress,
                    txtRejectionComments.Text);
                break;
            }

            case ContentWorkflowStatus.AwaitingPublishing:
            {
                workInProgress.RejectContentChanges(
                    currentUser.UserGuid,
                    txtRejectionComments.Text);

                WorkflowHelper.SendPublishRejectionNotification(
                    SiteUtils.GetSmtpSettings(),
                    siteSettings,
                    currentUser,
                    draftSubmitter,
                    workInProgress,
                    txtRejectionComments.Text);
                break;
            }
            }
            //end joe davis
            WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
        }
コード例 #26
0
        private string GetVirtualPath()
        {
            string virtualPath = string.Empty;

            if (siteSettings == null)
            {
                throw new ArgumentNullException("could not load SiteSettings");
            }

            int siteId = siteSettings.SiteId;

            if (WebConfigSettings.UseRelatedSiteMode && WebConfigSettings.UseSameContentFolderForRelatedSiteMode)
            {
                siteId = WebConfigSettings.RelatedSiteID;
            }

            virtualPath = "~/Data/Sites/" + siteId.ToInvariantString() + "/media/";

            if ((WebUser.IsAdminOrContentAdmin) || (SiteUtils.UserIsSiteEditor()))
            {
                if (WebConfigSettings.ForceAdminsToUseMediaFolder)
                {
                    virtualPath = "~/Data/Sites/" + siteId.ToInvariantString() + "/media/";
                }
                else
                {
                    if ((siteSettings.IsServerAdminSite) && (WebConfigSettings.AllowAdminsToUseDataFolder) && (WebUser.IsAdmin))
                    {
                        virtualPath = "~/Data/";
                    }
                    else
                    {
                        virtualPath = "~/Data/Sites/" + siteId.ToInvariantString() + "/";
                    }
                }
            }
            else if (WebUser.IsInRoles(siteSettings.GeneralBrowseAndUploadRoles))
            {
                virtualPath = "~/Data/Sites/" + siteId.ToInvariantString() + "/media/";
            }
            else if (WebUser.IsInRoles(siteSettings.UserFilesBrowseAndUploadRoles))
            {
                currentUser = SiteUtils.GetCurrentSiteUser();
                if (currentUser == null)
                {
                    throw new ArgumentNullException("could not load current SiteUser");
                }

                virtualPath = "~/Data/Sites/" + siteId.ToInvariantString() + "/userfiles/" + currentUser.UserId.ToInvariantString() + "/";
            }


            return(virtualPath);
        }
コード例 #27
0
ファイル: Edit.aspx.cs プロジェクト: pierreshiny/mojoportal
        void AddTrackButton_Click(object sender, EventArgs e)
        {
            if (SelectedFilesListBox.Items.Count > 0)
            {
                MediaTrack mt = new MediaTrack();

                //Populate the MediaTrack object.
                mt.PlayerId   = thePlayer.PlayerId;
                mt.TrackType  = thePlayer.PlayerType;
                mt.UserGuid   = SiteUtils.GetCurrentSiteUser().UserGuid;
                mt.Name       = TrackNameTextBox.Text;
                mt.Artist     = ArtistTextBox.Text;
                mt.TrackOrder = TracksGridView.Rows.Count + 1;

                try
                {
                    //Add the MediaTrack
                    mt.TrackId = MediaTrack.Add(mt);

                    //Add the MediaFiles
                    foreach (ListItem filePath in SelectedFilesListBox.Items)
                    {
                        MediaFile mf = new MediaFile();
                        mf.TrackId = mt.TrackId;
                        if (filePath.Text.StartsWith("http"))
                        {
                            mf.FilePath = filePath.Text;
                        }
                        else
                        {
                            mf.FilePath = "~" + filePath.Text;
                        }
                        mf.UserGuid = mt.UserGuid;
                        MediaFile.Add(mf);
                    }

                    RedirectToThisPage();
                }
                catch (Exception ex)
                {
                    //Perform backout actions of anything already saved
                    //The Forgien key of the MediaFiles table is set up with a Cascading delete, so
                    //the deleting of the MediaTracks will also delete any related MediaFiles.
                    MediaTrack.RemoveForPlayer(thePlayer.PlayerId);
                    //Display error to user
                    AddTrackErrorLabel.Text = ex.Message;
                }
            }
            else
            {
                AtLeastOneFileSelectedValidator.IsValid = false;
                AddTrackErrorLabel.Text = MediaPlayerResources.AtLeastOneFileSelectedValidatorErrorMessage;
            }
        }
コード例 #28
0
        private void PopulateControls()
        {
            if (SiteUtils.GetCurrentSiteUser() != null)
            {
                flagCheckIsUserAdmin = SiteUtils.GetCurrentSiteUser().IsInRoles(Resources.Resource.GiveAccessToAdmins);
            }
            DataSet ds = CustomCalenderEventBusiness.GetEvents(EventCalenderModuleID, FrmDate, ToDate);

            this.rptEvents.DataSource = ds;
            this.rptEvents.DataBind();
        }
コード例 #29
0
 private void LoadSettings()
 {
     siteSettings         = CacheHelper.GetCurrentSiteSettings();
     SiteRoot             = SiteUtils.GetNavigationSiteRoot();
     lnkClear.NavigateUrl = SiteRoot + "/DevAdmin/QueryTool.aspx";
     txtQuery.Language    = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
     dbPlatform           = DatabaseHelper.DBPlatform();
     queryId     = WebUtils.ParseGuidFromQueryString("qid", queryId);
     currentUser = SiteUtils.GetCurrentSiteUser();
     overrideConnectionString = WebConfigSettings.QueryToolOverrideConnectionString;
 }
コード例 #30
0
ファイル: KLBookPosted.ascx.cs プロジェクト: sang-nm/kinhluan
 private void LoadParams()
 {
     currentUser = SiteUtils.GetCurrentSiteUser();
     if (currentUser != null)
     {
         author = KLAuthor.GetKLAuthorByUserID(currentUser.UserId);
     }
     else
     {
         WebUtils.SetupRedirect(this, SiteRoot);
     }
 }