/// <summary>
        /// This method updates an existing content item
        /// </summary>
        /// <param name="tabId"></param>
        /// <param name="moduleId"></param>
        /// <param name="contentItemId"></param>
        /// <param name="bookmark"></param>
        /// <remarks>This method will only be present in DNN 6.2.3 and newer</remarks>
        public int UpdateContentItem(int tabId, int moduleId, int contentItemId, HangoutInfo hangout)
        {
            // get a reference to the original content item
            var objContent = Util.GetContentController().GetContentItem(contentItemId);

            // if the content item doesn't exist, send back to the calling method
            // NOTE:  Probably should just throw an exception here
            if (objContent == null)
            {
                return(Null.NullInteger);
            }

            // update the relevant properties
            objContent.Content = JsonExtensionsWeb.ToJsonString(hangout);

            // these are just for data posterity and probably don't need to be done
            objContent.ModuleID = moduleId;
            objContent.TabID    = tabId;

            // data integrity check for legacy data (just in case stuff)
            if (!Regex.IsMatch(objContent.ContentKey, CONTENT_KEY_FORMAT_PATTERN, RegexOptions.IgnoreCase))
            {
                objContent.ContentKey = string.Format(CONTENT_KEY_FORMAT, objContent.ContentItemId);
            }

            // execute the update on the database
            Util.GetContentController().UpdateContentItem(objContent);

            return(contentItemId);
        }
示例#2
0
        protected void btnUp_Upload(object sender, EventArgs e)
        {
            var folderManager = FolderManager.Instance;
            var userFolder    = folderManager.GetUserFolder(UserInfo);

            string    message = string.Empty;
            IFileInfo fi      = null;

            try {
                fi = FileManager.Instance.AddFile(userFolder, fileUp.PostedFile.FileName, fileUp.PostedFile.InputStream, true);
            } catch (PermissionsNotMetException) {
                message = string.Format(Localization.GetString("InsufficientFolderPermission"), userFolder.FolderPath);
            } catch (NoSpaceAvailableException) {
                message = string.Format(Localization.GetString("DiskSpaceExceeded"), fileUp.PostedFile.FileName);
            } catch (InvalidFileExtensionException) {
                message = string.Format(Localization.GetString("RestrictedFileType"), fileUp.PostedFile.FileName, Host.AllowedExtensionWhitelist.ToDisplayString());
            } catch {
                message = string.Format(Localization.GetString("SaveFileError"), fileUp.PostedFile.FileName);
            }
            if (String.IsNullOrEmpty(message) && fi != null)
            {
                litOut.Text = "<script type=\"text/javascript\">var fileInfo=" + JsonExtensionsWeb.ToJsonString(fi) + ";alert(fileInfo.FileName);</script>";
            }
            else
            {
                litOut.Text = message;
            }
        }
        /// <summary>
        /// This method creates new DNN Hangout entries in the content item data store
        /// </summary>
        /// <param name="tabId"></param>
        /// <param name="moduleId"></param>
        /// <param name="bookmark"></param>
        /// <returns></returns>
        public int CreateContentItem(int tabId, int moduleId, HangoutInfo hangout)
        {
            // create a new content item
            var objContent = new ContentItem
            {
                Content       = JsonExtensionsWeb.ToJsonString(hangout),
                ContentTypeId = DNNHangoutContentTypeId,
                Indexed       = false,
                ModuleID      = moduleId,
                TabID         = tabId
            };

            // save the content item to the database
            objContent.ContentItemId = Util.GetContentController().AddContentItem(objContent);

            // update the objects with the new content item id retrieved in the line above
            hangout.ContentItemId = objContent.ContentItemId;

            // update the content item properties with proper content
            objContent.Content    = JsonExtensionsWeb.ToJsonString(hangout);
            objContent.ContentKey = string.Format(CONTENT_KEY_FORMAT, hangout.ContentItemId);

            // update the content item again since we now have a contentItemId for the properties
            Util.GetContentController().UpdateContentItem(objContent);

            // return the content item id
            return(objContent.ContentItemId);
        }
示例#4
0
        protected void btnExecuteAction_Command(object sender, CommandEventArgs e)
        {
            // Cannot use DnnContext here?
            var actionHandler = new ActionHandler();
            var action        = JsonExtensionsWeb.FromJson <NewsEntryAction> ((string)e.CommandArgument);

            actionHandler.ExecuteAction(action, PortalSettings.Current.PortalId, PortalSettings.Current.ActiveTab.TabID, action.ModuleId);
        }
示例#5
0
        protected void linkActionButton_Command(object sender, CommandEventArgs e)
        {
            var actionHandler = new ActionHandler();
            var action        = JsonExtensionsWeb.FromJson <NewsEntryAction> ((string)e.CommandArgument);

            actionHandler.ExecuteAction(action,
                                        portalId: PortalSettings.Current.PortalId,
                                                    // TODO: Get superuser
                                        userId: 1); // as superuser
        }
示例#6
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            List <ValidateCheckInfo> clientSideChecks = new List <ValidateCheckInfo>();
            List <ValidateCheckInfo> serverSideChecks = new List <ValidateCheckInfo>();
            List <CheckInfo>         checks           = DataController.GetChecks(ModuleId);

            foreach (CheckInfo checkInfo in checks)
            {
                foreach (string qsKey in Request.QueryString.Keys.Cast <string>())
                {
                    var keyValue = qsKey + "=" + Request.QueryString[qsKey];
                    foreach (string checkValue in checkInfo.Querystring.Split(','))
                    {
                        bool isVisible = keyValue == checkValue || Regex.IsMatch(keyValue, checkValue);
                        if (isVisible)
                        {
                            if (checkInfo.ServerSide)
                            {
                                if (!serverSideChecks.Exists(x => x.ModuleID == checkInfo.CheckModuleID && x.Visible))
                                {
                                    serverSideChecks.Add(new ValidateCheckInfo()
                                    {
                                        ModuleID = checkInfo.CheckModuleID, Visible = !checkInfo.HideMatch
                                    });
                                }
                            }
                            else
                            {
                                if (!clientSideChecks.Exists(x => x.ModuleID == checkInfo.CheckModuleID && x.Visible))
                                {
                                    clientSideChecks.Add(new ValidateCheckInfo()
                                    {
                                        ModuleID = checkInfo.CheckModuleID, Visible = !checkInfo.HideMatch
                                    });
                                }
                            }
                        }
                    }
                }

                //Additional validation on the checkInfo in case there was not a querystring to test against.
                if (checkInfo.ServerSide)
                {
                    if (!serverSideChecks.Exists(x => x.ModuleID == checkInfo.CheckModuleID && x.Visible))
                    {
                        serverSideChecks.Add(new ValidateCheckInfo()
                        {
                            ModuleID = checkInfo.CheckModuleID, Visible = checkInfo.HideMatch
                        });
                    }
                }
                else
                {
                    if (!clientSideChecks.Exists(x => x.ModuleID == checkInfo.CheckModuleID && x.Visible))
                    {
                        clientSideChecks.Add(new ValidateCheckInfo()
                        {
                            ModuleID = checkInfo.CheckModuleID, Visible = checkInfo.HideMatch
                        });
                    }
                }
            }

            if (!IsEditable)
            {
                //Hide Modules only if not an admin.
                foreach (ValidateCheckInfo validateCheckInfo in serverSideChecks)
                {
                    if (!validateCheckInfo.Visible)
                    {
                        var control = ControlUtilities.FindFirstDescendent <Control>(Page, x => x.ID == "ctr" + validateCheckInfo.ModuleID.ToString());
                        if (control != null)
                        {
                            control.Visible = false;
                        }
                    }
                }

                //Add the QS Module to hide it. It needs to be visible server side because otherwise it won't output it's payload.
                clientSideChecks.Add(new ValidateCheckInfo()
                {
                    ModuleID = ModuleId, Visible = false
                });
                JsonOutput       = JsonExtensionsWeb.ToJson(clientSideChecks);
                plConfig.Visible = false;
            }
        }
示例#7
0
        protected void bAjaxPostback_Click(object sender, EventArgs e)
        {
            try
            {
                aqufitEntities entities = new aqufitEntities();
                Affine.Data.Managers.IDataManager dataMan = Affine.Data.Managers.LINQ.DataManager.Instance;
                long pId = -1;
                switch (hiddenAjaxAction.Value)
                {
                case "loadPhoto":
                    pId = Convert.ToInt64(hiddenAjaxValue.Value);
                    string url = SetupPhoto(pId);
                    RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Actions.LoadImage('" + url + "', " + lPhotoNum.Text + ");");
                    break;

                case "makeProfile":
                    pId = Convert.ToInt64(hiddenAjaxValue.Value);
                    Affine.Utils.ImageUtil.MakeProfileFromPhoto(UserSettings.Id, pId, Server.MapPath("~"));
                    string profileUrl = ResolveUrl("~") + UserSettings.UserName;
                    RadAjaxManager1.ResponseScripts.Add("top.location.href='" + profileUrl + "'; Aqufit.Page.atiLoading.remove();");
                    break;

                case "tagPhoto":
                    Affine.Data.Helpers.PhotoTag json = JsonExtensionsWeb.FromJson <Affine.Data.Helpers.PhotoTag>(hiddenAjaxValue.Value);
                    pId = Convert.ToInt64(hiddenPhotoId.Value);
                    // TODO: security
                    dataMan.TagPhoto(UserSettings.Id, json.FriendId, pId, json.Top, json.Left, json.Width, json.Height);
                    RadAjaxManager1.ResponseScripts.Add("radalert('<div style=\"width: 100%; height: 100%; padding: 0px;\"><span style=\"color: #FFF;\"><img src=\"" + ResolveUrl("~/DesktopModules/ATI_Base/resources/images/iCheck.png") + "\" align=\"absmiddle\"/> Photo has been tagged</span></div>', 330, 100, 'Success');");
                    break;

                case "addComment":
                    pId = Convert.ToInt64(hiddenPhotoId.Value);
                    string            comment = hiddenAjaxValue.Value;
                    AttachmentComment pc      = dataMan.SavePhotoComment(UserSettings.Id, pId, comment);
                    string            j       = new { UserName = pc.UserSetting.UserName, UserKey = pc.UserSetting.UserKey, Comment = pc.Comment }.ToJson();
                    RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.Actions.appendComment('" + j + "'); ");
                    break;

                case "deletePhoto":
                    pId = Convert.ToInt64(hiddenPhotoId.Value);
                    dataMan.DeletePhoto(UserSettings.Id, pId);
                    Response.Redirect(ResolveUrl("~") + UserSettings.UserName + "/photos", true);
                    //RadAjaxManager1.ResponseScripts.Add("alert('"+pId+"');");
                    break;

                case "deleteAlbum":
                    long aId = Convert.ToInt64(hiddenAlbumKey.Value);
                    dataMan.DeleteAlbum(UserSettings.Id, aId);
                    Response.Redirect(ResolveUrl("~") + UserSettings.UserName + "/photos", true);
                    //RadAjaxManager1.ResponseScripts.Add("alert('"+pId+"');");
                    break;

                case "deleteTag":
                    long       tId = Convert.ToInt64(hiddenAjaxValue.Value);
                    User2Photo u2p = entities.User2Photo.FirstOrDefault(p => p.Id == tId && (p.UserSettingsKey == UserSettings.Id || p.TaggerUserSettingsKey == UserSettings.Id));
                    if (u2p != null)
                    {
                        entities.DeleteObject(u2p);
                        entities.SaveChanges();
                        RadAjaxManager1.ResponseScripts.Add("radalert('<div style=\"width: 100%; height: 100%; padding: 0px;\"><span style=\"color: #FFF;\"><img src=\"" + ResolveUrl("~/DesktopModules/ATI_Base/resources/images/iCheck.png") + "\" align=\"absmiddle\"/> Tag has been removed</span></div>', 330, 100, 'Success');");
                    }
                    RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.atiLoading.remove(); ");
                    break;
                }
            }
            catch (Exception ex)
            {
                // TODO: better error handling
                RadAjaxManager1.ResponseScripts.Add(" alert('" + ex.Message + "'); ");
            }
        }