Inheritance: System.EventArgs
        protected void cv_UserAction(object sender, UserActionEventArgs e)
        {
            if (e.ActionName == "Save")
            {
                var contentView = e.ContentView;
                var content = contentView.Content;

                contentView.UpdateContent();

                if (contentView.IsUserInputValid && content.IsValid)
                {
                    try
                    {
                        var additionalTypes = new List<string>();
                        additionalTypes.Add("File");
                        var option = ((IEnumerable<string>)content["GroupAttachments"]).FirstOrDefault();
                        if (option != null)
                        {
                            switch (option)
                            {
                                case "subject":
                                case "sender":
                                    additionalTypes.Add("Folder");
                                    break;
                                case "email":
                                    additionalTypes.Add("Email");
                                    break;
                            }
                        }
                        ((GenericContent)content.ContentHandler).AllowChildTypes(additionalTypes);

                        content.Save();

                        // remove current workflow
                        RemoveWorkflow();

                        // start new workflow + subscription if email is given
                        var newEmail = content["ListEmail"] as string;
                        if (!string.IsNullOrEmpty(newEmail))
                            StartSubscription();

                        CallDone();
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteException(ex);
                        contentView.ContentException = ex;
                    }
                }
                return;
            }
            if (e.ActionName == "Cancel")
            {
                CallDone();
                return;
            }
        }
Exemplo n.º 2
0
        public void _contentView_UserAction(object sender, UserActionEventArgs e)
        {
            if (e.ActionName == "save")
            {
				e.ContentView.UpdateContent();
				if (e.ContentView.IsUserInputValid && _content.IsValid)
                {
                    string t = RepositoryPath.Combine(_content.ContentHandler.ParentPath, _content.Fields["Name"].GetData() as string);
                    //PathInfoRemove:
                    //if (RepositoryPathInfo.GetPathInfo(t) == null)
                    if (NodeHead.Get(t) == null)
                    {
                        _content.Save();
                        ProcessUserAction();
                    }
                    else
                    {
                        if (_content.ContentHandler.Id > 0)
                        {
                            _content.Save();
                            ProcessUserAction();
                        }
                        else
                        {
                            this._recreateEditContentView = false;
                            this._recreateNewContentView = false;
                            this._displayMode = GetViewModeName(ViewMode.Browse);
                            this._errorMessage = HttpContext.GetGlobalResourceObject("SingleContentPortlet", "ContentNameAlreadyExists") as string;
                        }
                    }
                }
                else
                {
                    this._recreateNewContentView = true;
                    _content.DontSave();
                }

            }
            else if (e.ActionName == "cancel")
            {
                _recreateNewContentView = false;
                _recreateEditContentView = false;
                _displayMode = GetViewModeName(ViewMode.Browse);
                _container.Controls.Clear();
                CreateChildControls();
            }
            else
            {
                this._recreateNewContentView = false;
                this._recreateEditContentView = false;
                _container.Controls.Clear();
            }
        }
Exemplo n.º 3
0
        void contentView_UserAction(object sender, UserActionEventArgs e)
        {
            var contentView = e.ContentView;
            var content = contentView.Content;

            switch (e.ActionName)
            {
                case "save":
                    OnSave(contentView, content);

                    if (!contentView.IsUserInputValid || !content.IsValid || contentView.ContentException != null)
                        return;

                    break;
            }

            CallDone();
        }
Exemplo n.º 4
0
		void _cvFormItem_UserAction(object sender, UserActionEventArgs e)
		{
			switch (e.ActionName)
			{
				case "save":
					e.ContentView.UpdateContent();
                    isContentValid = e.ContentView.Content.IsValid && e.ContentView.IsUserInputValid;
					if (e.ContentView.IsUserInputValid && e.ContentView.Content.IsValid)
					{
                        try
                        {
                            e.ContentView.Content.Save();
                            //if(_cvFormItem != null)
                            //	_cvFormItem.Controls.Clear();
                            Controls.Clear();

                            _formItemID = e.ContentView.Content.Id;

                            BuildAfterSubmitForm(e.ContentView.Content);
                        }
                        catch (FormatException ex) //logged
                        {
                            Logger.WriteException(ex);
                            e.ContentView.ContentException = new FormatException("Invalid format!", ex);
                        }
                        catch (Exception exc) //logged
                        {
                            Logger.WriteException(exc);
                            e.ContentView.ContentException = exc;
                        }
					}
					break;
			}
		}
Exemplo n.º 5
0
 void _cvAfterSubmitFormItem_UserAction(object sender, UserActionEventArgs e)
 {
     switch (e.ActionName)
     {
         case "ok":
             CreateControls();
             break;
     }
 }
Exemplo n.º 6
0
        void NewContentViewUserAction(object sender, UserActionEventArgs e)
        {
            var contentView = e.ContentView;
            var content = contentView.Content;

            contentView.UpdateContent();
            var backUrl = PortalContext.Current.BackUrl;
            if (String.IsNullOrEmpty(backUrl))
                backUrl = PortalContext.Current.RequestedUri.GetLeftPart(UriPartial.Path);
            switch (e.ActionName)
            {
                case "save":
                    if (contentView.IsUserInputValid && content.IsValid)
                    {
                        try
                        {
                            content.Save();

                            CallDone();
                        }
                        catch (Exception ex) //logged
                        {
                            Logger.WriteException(ex);
                            contentView.ContentException = ex;
                        }
                    }
                    break;
                case "cancel":
                    CurrentState = States[0];
                    SetControlsByState();

                    CallDone();
                    //HttpContext.Current.Response.Redirect(backUrl);

                    break;
            }
        }
Exemplo n.º 7
0
        void VotingItemNewContentViewUserAction(object sender, UserActionEventArgs e)
        {
            // If the button's action is not Save
            if (e.ActionName != "Save") return;

            if (!SecurityHandler.HasPermission(e.ContentView.ContentHandler, PermissionType.AddNew))
            {
                e.ContentView.ContentException = new Exception("You do not have the appropriate permissions to answer this question.");
                return;
            }

            e.ContentView.UpdateContent();
            if (e.ContentView.Content.IsValid)
            {
                e.ContentView.Content.Save();
                Controls.Clear();
                ChildControlsCreated = false;
                _myState = "ThankYouView";
            }
        }
 private void SetDefaultDomainValue(UserActionEventArgs e)
 {
     if (e == null) 
         throw new ArgumentNullException("e");
     var domain = Node.LoadNode(Configuration.DefaultDomainPath);
     e.ContentView.Content.Fields["Domain"].SetData(domain.Name);
 }
 protected virtual bool ChecksDuplicatedUser(UserActionEventArgs e)
 {
     if (Configuration.IsUniqueEmail)
     {
         var query = new NodeQuery();
         query.Add(new StringExpression(PropertyType.GetByName("Email"),StringOperator.Equal,(string)e.ContentView.Content.Fields["Email"].GetData()));
         var result = query.Execute();
         return result.Count > 0 ? true : false;
     }
     var path = e.ContentView.Content.ContentHandler.ParentPath;
     var newUserName = e.ContentView.Content.Fields["Name"].GetData() as string;
     var t = RepositoryPath.Combine(VirtualPathUtility.AppendTrailingSlash(path), newUserName);
     return NodeHead.Get(t) != null;
 }
Exemplo n.º 10
0
        private void AddToSecurityGroups(UserActionEventArgs e)
        {
            if (e == null)
                throw new ArgumentNullException("e");
            foreach (var n in Configuration.SecurityGroups)
            {
                try
                {
                    var g = Node.Load<SNC.Group>(n.Id);
                    if (g != null && g.Id != RepositoryConfiguration.EveryoneGroupId) // Only add to a group if it is not an empty group or the everyone group
                    {
                        var u = Node.LoadNode(e.ContentView.ContentHandler.Id) as User;
                        if (u != null)
                        {
							g.AddMember(u);
                            g.Save();
                        }
                    }
                }
                catch(Exception ee) //logged
                {
                    Logger.WriteException(ee);
                }
            }
        }
Exemplo n.º 11
0
        // Internals ////////////////////////////////////////////////////
        private void SaveUser(UserActionEventArgs e, bool createNew)
        {
            try
            {
                if (createNew)
                    GenerateActivationId();

                if (!Configuration.ActivationEnabled)
                    EnableAndActivateUser();

                _content.Save();

                if (createNew)
                    AddToSecurityGroups(e);
            }
            catch (InvalidOperationException ex) //logged
            {
                Logger.WriteException(ex);
                //TODO: Biztos, hogy UserAlreadyExists?
                WriteErrorMessageOnly(HttpContext.GetGlobalResourceObject("PublicRegistrationPortlet", "UserAlreadyExists") as string);
            }
        }
Exemplo n.º 12
0
        protected virtual void OnUserAction(UserActionEventArgs e, bool createNew)
        {
            var actionName = e.ActionName.ToLower();
            var actionName2 = Enum.GetName(typeof(ActionNames), ActionNames.Save).ToLower();
            if (!actionName.Equals(actionName2, StringComparison.InvariantCulture))
                return;
            
            ChangeToAdminAccount();

            if (createNew)
                SetDefaultDomainValue(e);

            e.ContentView.UpdateContent();
            if (e.ContentView.IsUserInputValid && _content.IsValid)
            {
                if (createNew && ChecksDuplicatedUser(e))
                {
                    WriteDuplactedUserErrorMessage();
                    
                    RestoreOriginalUser();
                    
                    return;
                }

                SaveUser(e, createNew);
            }
            this.RestoreOriginalUser();
        }
Exemplo n.º 13
0
 protected void ContentView_UserAction_New(object sender, UserActionEventArgs e)
 {
     OnUserAction(e, true);
 }
Exemplo n.º 14
0
        protected void ContentView_UserAction_Update(object sender, UserActionEventArgs e)
        {
            OnUserAction(e, false);
            if (e.ContentView.IsUserInputValid && e.ContentView.Content.IsValid)
                WriteMessage(Configuration.UpdateProfileSuccessTemplate);

        }