예제 #1
0
        private void SaveUser()
        {
            if (!Page.IsValid)
            {
                return;
            }

            // gather data from form
            UserInfo user = new UserInfo();

            user.UserId   = 0;
            user.Role     = (UserRole)Enum.Parse(typeof(UserRole), role.SelectedValue);
            user.StatusId = Int32.Parse(status.SelectedValue);
            user.OwnerId  = PanelSecurity.SelectedUserId;
            user.IsDemo   = chkDemo.Checked;
            user.IsPeer   = false;

            // account info
            user.FirstName        = txtFirstName.Text;
            user.LastName         = txtLastName.Text;
            user.SubscriberNumber = txtSubscriberNumber.Text;
            user.Email            = txtEmail.Text;
            user.SecondaryEmail   = txtSecondaryEmail.Text;
            user.HtmlMail         = ddlMailFormat.SelectedIndex == 1;
            user.Username         = txtUsername.Text.Trim();
//            user.Password = userPassword.Password;

            // contact info
            user.CompanyName      = contact.CompanyName;
            user.Address          = contact.Address;
            user.City             = contact.City;
            user.Country          = contact.Country;
            user.State            = contact.State;
            user.Zip              = contact.Zip;
            user.PrimaryPhone     = contact.PrimaryPhone;
            user.SecondaryPhone   = contact.SecondaryPhone;
            user.Fax              = contact.Fax;
            user.InstantMessenger = contact.MessengerId;


            // add a new user
            List <string> log = new List <string>();

            try
            {
                //int userId = UsersHelper.AddUser(log, PortalId, user);
                int userId = PortalUtils.AddUserAccount(log, user, chkAccountLetter.Checked, userPassword.Password);

                if (userId == BusinessErrorCodes.ERROR_INVALID_USER_NAME)
                {
                    ShowResultMessage(BusinessErrorCodes.ERROR_INVALID_USER_NAME);
                    return;
                }

                if (userId < 0)
                {
                    ShowResultMessage(userId);
                    return;
                }

                // show log records if any
                if (log.Count > 0)
                {
                    blLog.Items.Clear();
                    foreach (string error in log)
                    {
                        blLog.Items.Add(error);
                    }

                    return;
                }

                // go to user home
                Response.Redirect(PortalUtils.GetUserHomePageUrl(userId));
            }
            catch (Exception ex)
            {
                ShowErrorMessage("USER_ADD_USER", ex);
                return;
            }
        }
예제 #2
0
 public string GetUserHomePageUrl(int userId)
 {
     return(PortalUtils.GetUserHomePageUrl(userId));
 }
예제 #3
0
        private void BindMenu(MenuItemCollection items, XmlNodeList nodes)
        {
            foreach (XmlNode node in nodes)
            {
                string pageId = null;
                if (node.Attributes["pageID"] != null)
                {
                    pageId = node.Attributes["pageID"].Value;
                }

                if (!PortalUtils.PageExists(pageId))
                {
                    continue;
                }

                string url = null;
                if (node.Attributes["url"] != null)
                {
                    url = node.Attributes["url"].Value;
                }

                string title = null;
                if (node.Attributes["title"] != null)
                {
                    title = node.Attributes["title"].Value;
                }

                string target = null;
                if (node.Attributes["target"] != null)
                {
                    target = node.Attributes["target"].Value;
                }

                string resourceGroup = null;
                if (node.Attributes["resourceGroup"] != null)
                {
                    resourceGroup = node.Attributes["resourceGroup"].Value;
                }

                string quota = null;
                if (node.Attributes["quota"] != null)
                {
                    quota = node.Attributes["quota"].Value;
                }

                bool disabled = false;
                if (node.Attributes["disabled"] != null)
                {
                    disabled = Utils.ParseBool(node.Attributes["disabled"].Value, false);
                }

                // get custom page parameters
                XmlNodeList   xmlParameters = node.SelectNodes("Parameters/Add");
                List <string> parameters    = new List <string>();
                foreach (XmlNode xmlParameter in xmlParameters)
                {
                    parameters.Add(xmlParameter.Attributes["name"].Value
                                   + "=" + xmlParameter.Attributes["value"].Value);
                }

                // add menu item
                string pageUrl = !String.IsNullOrEmpty(url) ? url : PortalUtils.NavigatePageURL(
                    pageId, PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), parameters.ToArray());
                string   pageName = !String.IsNullOrEmpty(title) ? title : PortalUtils.GetLocalizedPageName(pageId);
                MenuItem item     = new MenuItem(pageName, "", "", disabled ? null : pageUrl);

                if (!String.IsNullOrEmpty(target))
                {
                    item.Target = target;
                }
                item.Selectable = !disabled;

                // check groups/quotas
                bool display = true;
                if (cntx != null)
                {
                    display = (String.IsNullOrEmpty(resourceGroup) ||
                               cntx.Groups.ContainsKey(resourceGroup)) &&
                              (String.IsNullOrEmpty(quota) ||
                               (cntx.Quotas.ContainsKey(quota) &&
                                cntx.Quotas[quota].QuotaAllocatedValue != 0));
                }

                if (display)
                {
                    // process nested menu items
                    XmlNodeList xmlNestedNodes = node.SelectNodes("MenuItems/MenuItem");
                    BindMenu(item.ChildItems, xmlNestedNodes);
                }

                if (display && !(disabled && item.ChildItems.Count == 0))
                {
                    items.Add(item);
                }
            }
        }
예제 #4
0
 public string GetNestedSpacesPageUrl(string parameterName, string parameterValue)
 {
     return(NavigatePageURL(PortalUtils.GetNestedSpacesPageId(),
                            PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(),
                            parameterName + "=" + parameterValue));
 }
예제 #5
0
        private void BindMenu(MenuItemCollection items, XmlNodeList nodes)
        {
            bool ecUserEnabled  = false;
            bool ecAdminEnabled = PanelSecurity.SelectedUser.EcommerceEnabled;
            //
            UserInfo parent = UsersHelper.GetUser(PanelSecurity.SelectedUser.OwnerId);

            //
            if (parent != null)
            {
                ecUserEnabled = parent.EcommerceEnabled;
            }

            foreach (XmlNode node in nodes)
            {
                string pageId = null;
                if (node.Attributes["pageID"] != null)
                {
                    pageId = node.Attributes["pageID"].Value;
                }

                if (!PortalUtils.PageExists(pageId))
                {
                    continue;
                }

                string url = null;
                if (node.Attributes["url"] != null)
                {
                    url = node.Attributes["url"].Value;
                }

                string title = null;
                if (node.Attributes["title"] != null)
                {
                    title = node.Attributes["title"].Value;
                }

                string target = null;
                if (node.Attributes["target"] != null)
                {
                    target = node.Attributes["target"].Value;
                }

                string roles = null;
                if (node.Attributes["roles"] != null)
                {
                    roles = node.Attributes["roles"].Value;
                }

                string selectedUserContext = null;
                if (node.Attributes["selectedUserContext"] != null)
                {
                    selectedUserContext = node.Attributes["selectedUserContext"].Value;
                }

                // get custom page parameters
                XmlNodeList   xmlParameters = node.SelectNodes("Parameters/Add");
                List <string> parameters    = new List <string>();
                foreach (XmlNode xmlParameter in xmlParameters)
                {
                    parameters.Add(xmlParameter.Attributes["name"].Value
                                   + "=" + xmlParameter.Attributes["value"].Value);
                }

                bool display = true;
                // set user role visibility second
                if (!String.IsNullOrEmpty(selectedUserContext))
                {
                    display = false;
                    string[] arrRoles = selectedUserContext.Split(',');
                    string   userRole = PanelSecurity.SelectedUser.Role.ToString();
                    foreach (string role in arrRoles)
                    {
                        if (String.Compare(userRole, role, true) == 0)
                        {
                            display = true;
                            break;
                        }
                    }
                }

                if ((!String.IsNullOrEmpty(roles)) & display)
                {
                    display = false;
                    string[] arrRoles = roles.Split(',');
                    string   userRole = PanelSecurity.LoggedUser.Role.ToString();
                    foreach (string role in arrRoles)
                    {
                        if (String.Compare(userRole, role, true) == 0)
                        {
                            display = true;
                            break;
                        }
                    }
                }
                // set ecommerce user visibility first
                if (display && node.Attributes["ecuser"] != null)
                {
                    display = ecUserEnabled;
                }
                // set ecommerce admin visibility third
                if (display && node.Attributes["ecadmin"] != null)
                {
                    display = ecAdminEnabled;
                }


                //Audit Log functionality is disabled when user is in Demo mode
                if ((pageId == "AuditLog") && (PanelSecurity.SelectedUser.IsDemo))
                {
                    display = false;
                }

                // add menu item
                if (display)
                {
                    string pageUrl = !String.IsNullOrEmpty(url) ? url : PortalUtils.NavigatePageURL(
                        pageId, PortalUtils.USER_ID_PARAM, PanelSecurity.SelectedUserId.ToString(), parameters.ToArray());
                    string   pageName = !String.IsNullOrEmpty(title) ? title : PortalUtils.GetLocalizedPageName(pageId);
                    MenuItem item     = new MenuItem(pageName, "", "", pageUrl);

                    if (!String.IsNullOrEmpty(target))
                    {
                        item.Target = target;
                    }

                    items.Add(item);

                    // process nested menu items
                    XmlNodeList xmlNestedNodes = node.SelectNodes("MenuItems/MenuItem");
                    BindMenu(item.ChildItems, xmlNestedNodes);
                }
            }
        }
예제 #6
0
 public string GetSpaceHomePageUrl(int spaceId)
 {
     return(PortalUtils.GetSpaceHomePageUrl(spaceId));
 }
예제 #7
0
 private void BindCountries()
 {
     PortalUtils.LoadCountriesDropDownList(lstCountries, null);
     lstCountries.Items.Insert(0, new ListItem(GetSharedLocalizedString("ListItem.NotSpecified"), ""));
 }
        private void SaveUser()
        {
            if (Page.IsValid)
            {
                // gather data from form
                UserInfo user = new UserInfo();
                user.UserId = PanelSecurity.SelectedUserId;
                user.Role   = (UserRole)Enum.Parse(typeof(UserRole), role.SelectedValue);
                user.IsDemo = chkDemo.Checked;
                user.Status = ViewState[UserStatusConst] != null ? (UserStatus)ViewState[UserStatusConst]: UserStatus.Active;
                //
                user.EcommerceEnabled = chkEcommerceEnbl.Checked;

                user.LoginStatusId = loginStatus.SelectedIndex;

                // account info
                user.FirstName        = txtFirstName.Text;
                user.LastName         = txtLastName.Text;
                user.SubscriberNumber = txtSubscriberNumber.Text;
                user.Email            = txtEmail.Text;
                user.SecondaryEmail   = txtSecondaryEmail.Text;
                user.HtmlMail         = ddlMailFormat.SelectedIndex == 1;

                // contact info
                user.CompanyName      = contact.CompanyName;
                user.Address          = contact.Address;
                user.City             = contact.City;
                user.Country          = contact.Country;
                user.State            = contact.State;
                user.Zip              = contact.Zip;
                user.PrimaryPhone     = contact.PrimaryPhone;
                user.SecondaryPhone   = contact.SecondaryPhone;
                user.Fax              = contact.Fax;
                user.InstantMessenger = contact.MessengerId;

                // update existing user
                try
                {
                    int result = PortalUtils.UpdateUserAccount(/*TaskID, */ user);

                    //int result = ES.Services.Users.UpdateUserTaskAsynchronously(TaskID, user);
                    AsyncTaskID = TaskID;

                    if (result.Equals(-102))
                    {
                        if (user.RoleId.Equals(3))
                        {
                            ShowResultMessage(result);
                            return;
                        }
                    }
                    else
                    {
                        if (result < 0)
                        {
                            ShowResultMessage(result);
                            return;
                        }
                    }
                }
                catch (Exception ex)
                {
                    ShowErrorMessage("USER_UPDATE_USER", ex);
                    return;
                }

                // return back to the list
                RedirectAccountHomePage();
            }
        }
예제 #9
0
 protected string GetNavigateDiskspaceDetails(int packageId)
 {
     return(PortalUtils.NavigatePageURL("DiskspaceReport", PortalUtils.SPACE_ID_PARAM, packageId.ToString(),
                                        "ctl=edit", "moduleDefId=DiskspaceReport"));
 }