private void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                lstLANGUAGE.DataSource = SplendidCache.Languages();
                lstLANGUAGE.DataBind();
                lstLANGUAGE.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
                Utils.SetValue(lstLANGUAGE, L10N.NormalizeCulture(L10n.NAME));

                lstMODULE_NAME.DataSource = SplendidCache.Modules();
                lstMODULE_NAME.DataBind();
                lstMODULE_NAME.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));

                lstLIST_NAME.DataSource = SplendidCache.TerminologyPickLists();
                lstLIST_NAME.DataBind();
                lstLIST_NAME.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
            }
            if (!chkINCLUDE_LISTS.Checked)
            {
                lstLIST_NAME.SelectedIndex = 0;
            }
            lstLIST_NAME.Enabled = chkINCLUDE_LISTS.Checked;
            if (chkGLOBAL_TERMS.Checked)
            {
                lstMODULE_NAME.SelectedIndex = 0;
            }
            lstMODULE_NAME.Enabled = !chkGLOBAL_TERMS.Checked;
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                // 06/09/2006 Paul.  Remove data binding in the user controls.  Binding is required, but only do so in the ASPX pages.
                //Page.DataBind();
                if (!IsPostBack)
                {
                    lstLANGUAGE.DataSource = SplendidCache.Languages();
                    lstLANGUAGE.DataBind();
                    lstTHEME.DataSource = SplendidCache.Themes();
                    lstTHEME.DataBind();

                    string sDefaultUserName = Sql.ToString(Application["CONFIG.default_user_name"]);
                    string sDefaultPassword = Sql.ToString(Application["CONFIG.default_password"]);
                    string sDefaultTheme    = Sql.ToString(Application["CONFIG.default_theme"]);
                    string sDefaultLanguage = Sql.ToString(Application["CONFIG.default_language"]);
                    txtUSER_NAME.Text = sDefaultUserName;
                    txtPASSWORD.Text  = sDefaultPassword;
                    try
                    {
                        sDefaultTheme          = Sql.IsEmptyString(sDefaultTheme) ? "Sugar" : sDefaultTheme;
                        lstTHEME.SelectedValue = sDefaultTheme;
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message);
                    }
                    try
                    {
                        sDefaultLanguage          = Sql.IsEmptyString(sDefaultLanguage) ? "en-US" : sDefaultLanguage;
                        lstLANGUAGE.SelectedValue = L10N.NormalizeCulture(sDefaultLanguage);
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message);
                        lblError.Text += ex.Message;
                    }
                    // 11/19/2005 Paul.  Don't show the Login & Password if Windows Authentication.
                    tblUser.Visible         = !Security.IsWindowsAuthentication();
                    lblInstructions.Visible = tblUser.Visible;
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                lblError.Text = ex.Message;
            }
        }
Esempio n. 3
0
 private void Page_Load(object sender, System.EventArgs e)
 {
     if (!IsPostBack)
     {
         if (lstDROPDOWN_OPTIONS.DataSource == null)
         {
             lstDROPDOWN_OPTIONS.DataSource = SplendidCache.TerminologyPickLists();
             lstDROPDOWN_OPTIONS.DataBind();
         }
         if (lstLANGUAGE_OPTIONS.DataSource == null)
         {
             lstLANGUAGE_OPTIONS.DataSource = SplendidCache.Languages();
             lstLANGUAGE_OPTIONS.DataBind();
             Utils.SetValue(lstLANGUAGE_OPTIONS, L10N.NormalizeCulture(L10n.NAME));
         }
     }
 }
        private void Page_Load(object sender, System.EventArgs e)
        {
            // 06/09/2006 Paul.  Remove data binding in the user controls.  Binding is required, but only do so in the ASPX pages.
            //this.DataBind();  // Need to bind so that Text of the Button gets updated.
            reqNAME.ErrorMessage = L10n.Term(".ERR_MISSING_REQUIRED_FIELDS") + " " + L10n.Term("Terminology.LBL_LIST_NAME") + "<br>";
            if (!IsPostBack)
            {
                // 01/12/2006 Paul.  Language cannot be null.
                lstLANGUAGE.DataSource = SplendidCache.Languages();
                lstLANGUAGE.DataBind();

                DataTable dtModules = SplendidCache.Modules().Copy();
                dtModules.Rows.InsertAt(dtModules.NewRow(), 0);
                lstMODULE_NAME.DataSource = dtModules;
                lstMODULE_NAME.DataBind();
                // 01/12/2006 Paul.  Insert is failing, but I don't know why.
                // It might be because the NewRecord control is loaded using LoadControl.
                // Very odd as the Search Control is not having a problem inserting a value.
                //lstMODULE_NAME.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));

                DataTable dtPickLists = SplendidCache.TerminologyPickLists().Copy();
                dtPickLists.Rows.InsertAt(dtPickLists.NewRow(), 0);
                lstLIST_NAME.DataSource = dtPickLists;
                lstLIST_NAME.DataBind();
                //lstLIST_NAME.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));

                try
                {
                    // 01/12/2006 Paul.  Set default value to current language.
                    // 01/12/2006 Paul.  This is not working.  Use client-side script to select the default.
                    lstLANGUAGE.SelectedValue = L10N.NormalizeCulture(L10n.NAME);
                }
                catch (Exception ex)
                {
                    SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                }
                //this.DataBind();
            }
        }
Esempio n. 5
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term(".moduleList.Terminology"));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            this.Visible = SplendidCRM.Security.IS_ADMIN;
            if (!this.Visible)
            {
                return;
            }

            try
            {
                gID = Sql.ToGuid(Request["ID"]);
                if (!IsPostBack)
                {
                    lstLANGUAGE.DataSource = SplendidCache.Languages();
                    lstLANGUAGE.DataBind();

                    lstMODULE_NAME.DataSource = SplendidCache.Modules();
                    lstMODULE_NAME.DataBind();
                    lstMODULE_NAME.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));

                    lstLIST_NAME.DataSource = SplendidCache.TerminologyPickLists();
                    lstLIST_NAME.DataBind();
                    lstLIST_NAME.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));

                    Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]);
                    if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID))
                    {
                        DbProviderFactory dbf = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            string sSQL;
                            sSQL = "select *                 " + ControlChars.CrLf
                                   + "  from vwTERMINOLOGY_Edit" + ControlChars.CrLf
                                   + " where ID = @ID          " + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                Sql.AddParameter(cmd, "@ID", gID);
                                con.Open();

                                if (bDebug)
                                {
                                    RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd));
                                }

                                using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                {
                                    if (rdr.Read())
                                    {
                                        ctlModuleHeader.Title = Sql.ToString(rdr["NAME"]);
                                        SetPageTitle(L10n.Term(".moduleList.Terminology") + " - " + ctlModuleHeader.Title);
                                        ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title;

                                        // 01/20/2006 Paul.  Don't allow the name to be changed.  Require a new term.
                                        txtNAME.ReadOnly = true;

                                        txtNAME.Text         = Sql.ToString(rdr["NAME"]);
                                        txtDISPLAY_NAME.Text = Sql.ToString(rdr["DISPLAY_NAME"]);
                                        if (Sql.ToInteger(rdr["LIST_ORDER"]) > 0)
                                        {
                                            txtLIST_ORDER.Text = Sql.ToString(rdr["LIST_ORDER"]);
                                        }
                                        try
                                        {
                                            lstLANGUAGE.SelectedValue = L10N.NormalizeCulture(Sql.ToString(rdr["LANG"]));
                                        }
                                        catch
                                        {
                                        }
                                        string sMODULE_NAME = Sql.ToString(rdr["MODULE_NAME"]);
                                        try
                                        {
                                            lstMODULE_NAME.SelectedValue = sMODULE_NAME;
                                        }
                                        catch
                                        {
                                            // 01/12/2006 Paul.  If module does not exist in our table, then add it to prevent data loss.
                                            lstMODULE_NAME.Items.Add(sMODULE_NAME);
                                            lstMODULE_NAME.SelectedValue = sMODULE_NAME;
                                        }
                                        try
                                        {
                                            lstLIST_NAME.SelectedValue = Sql.ToString(rdr["LIST_NAME"]);
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    // 12/02/2005 Paul.  When validation fails, the header title does not retain its value.  Update manually.
                    ctlModuleHeader.Title = Sql.ToString(ViewState["ctlModuleHeader.Title"]);
                    SetPageTitle(L10n.Term(".moduleList.Administration") + " - " + ctlModuleHeader.Title);
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                ctlEditButtons.ErrorText = ex.Message;
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term(".moduleList." + m_sMODULE));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            // 07/11/2006 Paul.  Users must be able to view and edit their own settings.
            this.Visible = bMyAccount || SplendidCRM.Security.IS_ADMIN;              //(SplendidCRM.Security.GetUserAccess(m_sMODULE, "view") >= 0);
            if (!this.Visible)
            {
                return;
            }

            try
            {
                gID = Sql.ToGuid(Request["ID"]);
                if (bMyAccount)
                {
                    // 11/19/2005 Paul.  SugarCRM 3.5.0 allows administrator to duplicate itself.
                    btnDuplicate.Visible = Security.IS_ADMIN;
                    gID = Security.USER_ID;
                }
                ctlAccessView.USER_ID = gID;

                // 12/06/2005 Paul.  The password button is only visible if not windows authentication or Admin.
                // The reason to allow the admin to change a password is so that the admin can prepare to turn off windows authentication.
                btnChangePassword.Visible = !Security.IsWindowsAuthentication() || Security.IS_ADMIN;
                btnReset.Visible          = Security.IS_ADMIN;
                if (!Sql.IsEmptyString(txtNEW_PASSWORD.Value))
                {
                    bool bValidOldPassword = false;
                    if (!Security.IS_ADMIN)
                    {
                        DbProviderFactory dbf = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            string sSQL;
                            // 07/17/2006 Paul.  The USER_HASH has been removed from the main vwUSERS view to prevent its use in reports.
                            sSQL = "select *                     " + ControlChars.CrLf
                                   + "  from vwUSERS_Login         " + ControlChars.CrLf
                                   + " where ID        = @ID       " + ControlChars.CrLf
                                   + "   and USER_HASH = @USER_HASH" + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                Sql.AddParameter(cmd, "@ID", gID);
                                Sql.AddParameter(cmd, "@USER_HASH", Security.HashPassword(txtOLD_PASSWORD.Value));
                                con.Open();
                                using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                {
                                    if (rdr.Read())
                                    {
                                        bValidOldPassword = true;
                                    }
                                }
                            }
                        }
                        if (!bValidOldPassword)
                        {
                            lblError.Text = L10n.Term("Users.ERR_PASSWORD_INCORRECT_OLD");
                        }
                    }
                    if (bValidOldPassword || Security.IS_ADMIN)
                    {
                        if (txtNEW_PASSWORD.Value == txtCONFIRM_PASSWORD.Value)
                        {
                            SqlProcs.spUSERS_PasswordUpdate(gID, Security.HashPassword(txtNEW_PASSWORD.Value));
                            if (bMyAccount)
                            {
                                Response.Redirect("MyAccount.aspx");
                            }
                            else
                            {
                                Response.Redirect("view.aspx?ID=" + gID.ToString());
                            }
                        }
                        else
                        {
                            lblError.Text = L10n.Term("Users.ERR_REENTER_PASSWORDS");
                        }
                    }
                }
                if (!IsPostBack)
                {
                    // 05/09/2006 Paul.  We need to always initialize the separators, just in case the user is new.
                    txtGROUP_SEPARATOR.Text   = SplendidDefaults.GroupSeparator();
                    txtDECIMAL_SEPARATOR.Text = SplendidDefaults.DecimalSeparator();
                    if (!Sql.IsEmptyGuid(gID))
                    {
                        DbProviderFactory dbf = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            string sSQL;
                            sSQL = "select *           " + ControlChars.CrLf
                                   + "  from vwUSERS_Edit" + ControlChars.CrLf
                                   + " where ID = @ID    " + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                Sql.AddParameter(cmd, "@ID", gID);
                                con.Open();

                                if (bDebug)
                                {
                                    RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd));
                                }

                                using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                {
                                    if (rdr.Read())
                                    {
                                        ctlModuleHeader.Title = Sql.ToString(rdr["FULL_NAME"]) + " (" + Sql.ToString(rdr["USER_NAME"]) + ")";
                                        SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title);
                                        Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title);

                                        // main
                                        txtNAME.Text      = Sql.ToString(rdr["FULL_NAME"]);
                                        txtUSER_NAME.Text = Sql.ToString(rdr["USER_NAME"]);
                                        txtSTATUS.Text    = Sql.ToString(L10n.Term(".user_status_dom.", rdr["STATUS"]));
                                        // user_settings
                                        chkIS_ADMIN.Checked              = Sql.ToBoolean(rdr["IS_ADMIN"]);
                                        chkPORTAL_ONLY.Checked           = Sql.ToBoolean(rdr["PORTAL_ONLY"]);
                                        chkRECEIVE_NOTIFICATIONS.Checked = Sql.ToBoolean(rdr["RECEIVE_NOTIFICATIONS"]);

                                        this.AppendDetailViewFields(m_sMODULE + ".DetailView", tblMain, rdr);
                                        // 08/05/2006 Paul.  MailOptions are populated manually.
                                        this.AppendDetailViewFields(m_sMODULE + ".MailOptions", tblMailOptions, null);
                                        // 01/20/2008 Paul.  The mail options panel is manually populated.
                                        new DynamicControl(this, "EMAIL1").Text = Sql.ToString(rdr["EMAIL1"]);
                                        new DynamicControl(this, "EMAIL2").Text = Sql.ToString(rdr["EMAIL2"]);

                                        string sUSER_PREFERENCES = Sql.ToString(rdr["USER_PREFERENCES"]);
                                        if (!Sql.IsEmptyString(sUSER_PREFERENCES))
                                        {
                                            XmlDocument xml = SplendidInit.InitUserPreferences(sUSER_PREFERENCES);
                                            try
                                            {
                                                // user_settings
                                                txtLANGUAGE.Text = L10N.NormalizeCulture(XmlUtil.SelectSingleNode(xml, "culture"));
                                                try
                                                {
                                                    DataView vwLanguages = new DataView(SplendidCache.Languages());
                                                    vwLanguages.RowFilter = "NAME = '" + txtLANGUAGE.Text + "'";
                                                    if (vwLanguages.Count > 0)
                                                    {
                                                        txtLANGUAGE.Text = Sql.ToString(vwLanguages[0]["NATIVE_NAME"]);
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                                }
                                                txtDATEFORMAT.Text = XmlUtil.SelectSingleNode(xml, "dateformat");
                                                txtTIMEFORMAT.Text = XmlUtil.SelectSingleNode(xml, "timeformat");
                                                // 08/05/2006 Paul.  Remove stub of unsupported code. Show Gridline is not supported at this time.
                                                //chkGRIDLINE             .Checked = Sql.ToBoolean(XmlUtil.SelectSingleNode(xml, "gridline"             ));
                                                // mail_options
                                                new DynamicControl(this, "MAIL_FROMNAME").Text        = XmlUtil.SelectSingleNode(xml, "mail_fromname");
                                                new DynamicControl(this, "MAIL_FROMADDRESS").Text     = XmlUtil.SelectSingleNode(xml, "mail_fromaddress");
                                                new DynamicControl(this, "MAIL_SENDTYPE").Text        = XmlUtil.SelectSingleNode(xml, "mail_sendtype");
                                                new DynamicControl(this, "MAIL_SMTPSERVER").Text      = XmlUtil.SelectSingleNode(xml, "mail_smtpserver");
                                                new DynamicControl(this, "MAIL_SMTPPORT").Text        = XmlUtil.SelectSingleNode(xml, "mail_smtpport");
                                                new DynamicControl(this, "MAIL_SMTPAUTH_REQ").Checked = Sql.ToBoolean(XmlUtil.SelectSingleNode(xml, "mail_smtpauth_req"));
                                                new DynamicControl(this, "MAIL_SMTPUSER").Text        = XmlUtil.SelectSingleNode(xml, "mail_smtpuser");
                                                // freebusy
                                                // 08/05/2006 Paul.  Remove stub of unsupported code. Calendar Publish Key is not supported at this time.
                                                //txtCALENDAR_PUBLISH_KEY .Text    =               XmlUtil.SelectSingleNode(xml, "calendar_publish_key" );
                                                //txtCALENDAR_PUBLISH_URL .Text    =               XmlUtil.SelectSingleNode(xml, "calendar_publish_url" );
                                                //txtCALENDAR_SEARCH_URL  .Text    =               XmlUtil.SelectSingleNode(xml, "calendar_search_url"  );

                                                // 05/09/2006 Paul.  Initialize the numeric separators.
                                                txtGROUP_SEPARATOR.Text   = XmlUtil.SelectSingleNode(xml, "num_grp_sep");
                                                txtDECIMAL_SEPARATOR.Text = XmlUtil.SelectSingleNode(xml, "dec_sep");
                                                // 05/09/2006 Paul.  Check for empty strings as the user may have legacy data.
                                                if (Sql.IsEmptyString(txtGROUP_SEPARATOR.Text))
                                                {
                                                    txtGROUP_SEPARATOR.Text = SplendidDefaults.GroupSeparator();
                                                }
                                                if (Sql.IsEmptyString(txtDECIMAL_SEPARATOR.Text))
                                                {
                                                    txtDECIMAL_SEPARATOR.Text = SplendidDefaults.DecimalSeparator();
                                                }

                                                string   sTIMEZONE   = XmlUtil.SelectSingleNode(xml, "timezone");
                                                DataView vwTimezones = new DataView(SplendidCache.Timezones());
                                                vwTimezones.RowFilter = "ID = '" + sTIMEZONE + "'";
                                                if (vwTimezones.Count > 0)
                                                {
                                                    txtTIMEZONE.Text = Sql.ToString(vwTimezones[0]["NAME"]);
                                                }

                                                string   sCURRENCY    = XmlUtil.SelectSingleNode(xml, "currency_id");
                                                DataView vwCurrencies = new DataView(SplendidCache.Currencies());
                                                vwCurrencies.RowFilter = "ID = '" + sCURRENCY + "'";
                                                if (vwCurrencies.Count > 0)
                                                {
                                                    txtCURRENCY.Text = Sql.ToString(vwCurrencies[0]["NAME_SYMBOL"]);
                                                }
                                                // 08/05/2006 Paul.  Remove stub of unsupported code. Reminder is not supported at this time.

                                                /*
                                                 * try
                                                 * {
                                                 *      int nREMINDER_TIME = Sql.ToInteger(XmlUtil.SelectSingleNode(xml, "reminder_time"));
                                                 *      if ( nREMINDER_TIME > 0 )
                                                 *      {
                                                 *              txtREMINDER_TIME.Text = L10n.Term(".reminder_time_options." + nREMINDER_TIME.ToString());
                                                 *              chkREMINDER.Checked = true;
                                                 *      }
                                                 * }
                                                 * catch(Exception ex)
                                                 * {
                                                 *      SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                                 * }
                                                 */
                                            }
                                            catch (Exception ex)
                                            {
                                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                                            }
                                        }
                                        //txtDESCRIPTION.Text = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String("YToxODp7czo4OiJncmlkbGluZSI7czozOiJvZmYiO3M6ODoibWF4X3RhYnMiO3M6MjoiMTIiO3M6MTI6ImRpc3BsYXlfdGFicyI7YToxNTp7aTowO3M6NDoiSG9tZSI7aToxO3M6NzoiaUZyYW1lcyI7aToyO3M6ODoiQ2FsZW5kYXIiO2k6MztzOjEwOiJBY3Rpdml0aWVzIjtpOjQ7czo4OiJBY2NvdW50cyI7aTo1O3M6NToiTGVhZHMiO2k6NjtzOjEzOiJPcHBvcnR1bml0aWVzIjtpOjc7czo1OiJDYXNlcyI7aTo4O3M6NDoiQnVncyI7aTo5O3M6OToiRG9jdW1lbnRzIjtpOjEwO3M6NjoiRW1haWxzIjtpOjExO3M6OToiQ2FtcGFpZ25zIjtpOjEyO3M6NzoiUHJvamVjdCI7aToxMztzOjU6IkZlZWRzIjtpOjE0O3M6OToiRGFzaGJvYXJkIjt9czoxMzoicmVtaW5kZXJfdGltZSI7czozOiI5MDAiO3M6NToidGltZWYiO3M6MzoiSDppIjtzOjg6ImN1cnJlbmN5IjtzOjM6Ii05OSI7czo1OiJkYXRlZiI7czo1OiJZLW0tZCI7czo1OiJ0aW1leiI7czoxOiIwIjtzOjEzOiJtYWlsX2Zyb21uYW1lIjtzOjQ6IlBhdWwiO3M6MTY6Im1haWxfZnJvbWFkZHJlc3MiO3M6MTM6InBhdWxAcm9ueS5jb20iO3M6MTM6Im1haWxfc2VuZHR5cGUiO3M6NDoiU01UUCI7czoxNToibWFpbF9zbXRwc2VydmVyIjtzOjM6Im5zMSI7czoxMzoibWFpbF9zbXRwcG9ydCI7czoyOiIyMyI7czoxMzoibWFpbF9zbXRwdXNlciI7czo4OiJwYXVscm9ueSI7czoxMzoibWFpbF9zbXRwcGFzcyI7czo3OiJwb2NrZXQxIjtzOjE3OiJtYWlsX3NtdHBhdXRoX3JlcSI7czowOiIiO3M6MTY6Im1haWxfcG9wYXV0aF9yZXEiO3M6MDoiIjtzOjIwOiJjYWxlbmRhcl9wdWJsaXNoX2tleSI7czoxMToicHVibGlzaCBoZXkiO30="));
                                    }
                                }
                            }
                        }
                    }
                }
                // 06/09/2006 Paul.  Remove data binding in the user controls.  Binding is required, but only do so in the ASPX pages.
                //Page.DataBind();
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                lblError.Text = ex.Message;
            }
        }
Esempio n. 7
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term(".moduleList." + m_sMODULE));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            // 07/11/2006 Paul.  Users must be able to view and edit their own settings.
            this.Visible = bMyAccount || SplendidCRM.Security.IS_ADMIN;              //(SplendidCRM.Security.GetUserAccess(m_sMODULE, "edit") >= 0);
            if (!this.Visible)
            {
                return;
            }

            reqUSER_NAME.DataBind();
            reqLAST_NAME.DataBind();
            try
            {
                // 06/09/2006 Paul.  Remove data binding in the user controls.  Binding is required, but only do so in the ASPX pages.
                //Page.DataBind();
                gID = Sql.ToGuid(Request["ID"]);
                if (bMyAccount)
                {
                    gID = Security.USER_ID;
                }
                // 07/12/2006 Paul.  Status can only be edited by an administrator.
                lstSTATUS.Enabled = false;
                // 12/06/2005 Paul.  A user can only edit his own user name if Windows Authentication is off.
                if (Security.IS_ADMIN)
                {
                    // 12/06/2005 Paul.  An administrator can always edit the user name.  This is to allow him to pre-add any NTLM users.
                    txtUSER_NAME.Enabled = true;
                    lstSTATUS.Enabled    = true;
                }
                else if (gID == Security.USER_ID)
                {
                    // 12/06/2005 Paul.  If editing yourself, then you can only edit if not NTLM.
                    // txtUSER_NAME.Enabled = !Security.IsWindowsAuthentication();
                    // 11/26/2006 Paul.  A user cannot edit their own user name. This is a job for the admin.
                    txtUSER_NAME.Enabled = false;
                }
                else
                {
                    // 12/06/2005 Paul.  If not an administrator and not editing yourself, then the name cannot be edited.
                    txtUSER_NAME.Enabled = false;
                }

                if (!IsPostBack)
                {
                    // 'date_formats' => array('Y-m-d'=>'2006-12-23', 'm-d-Y'=>'12-23-2006', 'Y/m/d'=>'2006/12/23', 'm/d/Y'=>'12/23/2006')
                    // 'time_formats' => array('H:i'=>'23:00', 'h:ia'=>'11:00pm', 'h:iA'=>'11:00PM', 'H.i'=>'23.00', 'h.ia'=>'11.00pm', 'h.iA'=>'11.00PM' )
                    lstSTATUS.DataSource = SplendidCache.List("user_status_dom");
                    lstSTATUS.DataBind();
                    // 08/05/2006 Paul.  Remove stub of unsupported code. Reminder is not supported at this time.
                    //lstREMINDER_TIME  .DataSource = SplendidCache.List("reminder_time_dom");
                    //lstREMINDER_TIME  .DataBind();
                    lstTIMEZONE.DataSource = SplendidCache.TimezonesListbox();
                    lstTIMEZONE.DataBind();
                    lstCURRENCY.DataSource = SplendidCache.Currencies();
                    lstCURRENCY.DataBind();
                    // 05/09/2006 Paul.  We need to always initialize the separators, just in case the user is new.
                    txtGROUP_SEPARATOR.Text   = SplendidDefaults.GroupSeparator();
                    txtDECIMAL_SEPARATOR.Text = SplendidDefaults.DecimalSeparator();

                    lstLANGUAGE.DataSource = SplendidCache.Languages();
                    lstLANGUAGE.DataBind();
                    lstLANGUAGE_Changed(null, null);
                    lstTHEME.DataSource = SplendidCache.Themes();
                    lstTHEME.DataBind();

                    Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]);
                    if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID))
                    {
                        DbProviderFactory dbf = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            string sSQL;
                            sSQL = "select *           " + ControlChars.CrLf
                                   + "  from vwUSERS_Edit" + ControlChars.CrLf
                                   + " where ID = @ID    " + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                if (!Sql.IsEmptyGuid(gDuplicateID))
                                {
                                    Sql.AddParameter(cmd, "@ID", gDuplicateID);
                                    gID = Guid.Empty;
                                }
                                else
                                {
                                    Sql.AddParameter(cmd, "@ID", gID);
                                }
                                con.Open();

                                if (bDebug)
                                {
                                    RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd));
                                }

                                using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                {
                                    if (rdr.Read())
                                    {
                                        ctlModuleHeader.Title = Sql.ToString(rdr["FULL_NAME"]);
                                        SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title + " (" + Sql.ToString(rdr["USER_NAME"]) + ")");
                                        Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title);
                                        ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title;

                                        this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr);
                                        this.AppendEditViewFields(m_sMODULE + ".EditAddress", tblAddress, rdr);
                                        // 08/05/2006 Paul.  Use the dynamic grid to create the fields, but populate manually.
                                        this.AppendEditViewFields(m_sMODULE + ".EditMailOptions", tblMailOptions, null);
                                        // 01/20/2008 Paul.  The mail options panel is manually populated.
                                        new DynamicControl(this, "EMAIL1").Text = Sql.ToString(rdr["EMAIL1"]);
                                        new DynamicControl(this, "EMAIL2").Text = Sql.ToString(rdr["EMAIL2"]);

                                        // main
                                        txtUSER_NAME.Text  = Sql.ToString(rdr["USER_NAME"]);
                                        txtFIRST_NAME.Text = Sql.ToString(rdr["FIRST_NAME"]);
                                        txtLAST_NAME.Text  = Sql.ToString(rdr["LAST_NAME"]);
                                        // user_settings
                                        chkIS_ADMIN.Checked              = Sql.ToBoolean(rdr["IS_ADMIN"]);
                                        chkPORTAL_ONLY.Checked           = Sql.ToBoolean(rdr["PORTAL_ONLY"]);
                                        chkRECEIVE_NOTIFICATIONS.Checked = Sql.ToBoolean(rdr["RECEIVE_NOTIFICATIONS"]);
                                        // 12/04/2005 Paul.  Only allow the admin flag to be changed if the current user is an admin.
                                        chkIS_ADMIN.Enabled = Security.IS_ADMIN;
                                        // 12/04/2005 Paul.  Save admin flag in ViewState to prevent hacking.
                                        ViewState["IS_ADMIN"] = Sql.ToBoolean(rdr["IS_ADMIN"]);

                                        try
                                        {
                                            lstSTATUS.SelectedValue = Sql.ToString(rdr["STATUS"]);
                                        }
                                        catch (Exception ex)
                                        {
                                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                        }

                                        string sUSER_PREFERENCES = Sql.ToString(rdr["USER_PREFERENCES"]);
                                        if (!Sql.IsEmptyString(sUSER_PREFERENCES))
                                        {
                                            XmlDocument xml = SplendidInit.InitUserPreferences(sUSER_PREFERENCES);
                                            try
                                            {
                                                ViewState["USER_PREFERENCES"] = xml.OuterXml;
                                                // user_settings
                                                chkGRIDLINE.Checked = Sql.ToBoolean(XmlUtil.SelectSingleNode(xml, "gridline"));
                                                try
                                                {
                                                    lstLANGUAGE.SelectedValue = L10N.NormalizeCulture(XmlUtil.SelectSingleNode(xml, "culture"));
                                                    lstLANGUAGE_Changed(null, null);
                                                }
                                                catch (Exception ex)
                                                {
                                                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                                }
                                                try
                                                {
                                                    lstLANGUAGE.SelectedValue = XmlUtil.SelectSingleNode(xml, "theme");
                                                }
                                                catch (Exception ex)
                                                {
                                                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                                }
                                                try
                                                {
                                                    lstDATE_FORMAT.SelectedValue = XmlUtil.SelectSingleNode(xml, "dateformat");
                                                }
                                                catch (Exception ex)
                                                {
                                                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                                }
                                                try
                                                {
                                                    lstTIME_FORMAT.SelectedValue = XmlUtil.SelectSingleNode(xml, "timeformat");
                                                }
                                                catch (Exception ex)
                                                {
                                                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                                }
                                                try
                                                {
                                                    lstTIMEZONE.SelectedValue = XmlUtil.SelectSingleNode(xml, "timezone");
                                                }
                                                catch (Exception ex)
                                                {
                                                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                                }
                                                try
                                                {
                                                    lstCURRENCY.SelectedValue = XmlUtil.SelectSingleNode(xml, "currency_id");
                                                }
                                                catch (Exception ex)
                                                {
                                                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                                }

                                                // mail_options
                                                new DynamicControl(this, "MAIL_FROMNAME").Text        = XmlUtil.SelectSingleNode(xml, "mail_fromname");
                                                new DynamicControl(this, "MAIL_FROMADDRESS").Text     = XmlUtil.SelectSingleNode(xml, "mail_fromaddress");
                                                new DynamicControl(this, "MAIL_SENDTYPE").Text        = XmlUtil.SelectSingleNode(xml, "mail_sendtype");
                                                new DynamicControl(this, "MAIL_SMTPSERVER").Text      = XmlUtil.SelectSingleNode(xml, "mail_smtpserver");
                                                new DynamicControl(this, "MAIL_SMTPPORT").Text        = XmlUtil.SelectSingleNode(xml, "mail_smtpport");
                                                new DynamicControl(this, "MAIL_SMTPAUTH_REQ").Checked = Sql.ToBoolean(XmlUtil.SelectSingleNode(xml, "mail_smtpauth_req"));
                                                new DynamicControl(this, "MAIL_SMTPUSER").Text        = XmlUtil.SelectSingleNode(xml, "mail_smtpuser");
                                                new DynamicControl(this, "MAIL_SMTPPASS").Text        = XmlUtil.SelectSingleNode(xml, "mail_smtppass");

                                                ViewState["mail_smtppass"] = XmlUtil.SelectSingleNode(xml, "mail_smtppass");
                                                // 08/06/2005 Paul.  Never return password to user.
                                                TextBox txtMAIL_SMTPPASS = FindControl("MAIL_SMTPPASS") as TextBox;
                                                if (txtMAIL_SMTPPASS != null)
                                                {
                                                    if (!Sql.IsEmptyString(txtMAIL_SMTPPASS.Text))
                                                    {
                                                        txtMAIL_SMTPPASS.Text = sEMPTY_PASSWORD;
                                                    }
                                                }

                                                // 05/09/2006 Paul.  Initialize the numeric separators.
                                                txtGROUP_SEPARATOR.Text   = XmlUtil.SelectSingleNode(xml, "num_grp_sep");
                                                txtDECIMAL_SEPARATOR.Text = XmlUtil.SelectSingleNode(xml, "dec_sep");
                                                // 05/09/2006 Paul.  Check for empty strings as the user may have legacy data.
                                                if (Sql.IsEmptyString(txtGROUP_SEPARATOR.Text))
                                                {
                                                    txtGROUP_SEPARATOR.Text = SplendidDefaults.GroupSeparator();
                                                }
                                                if (Sql.IsEmptyString(txtDECIMAL_SEPARATOR.Text))
                                                {
                                                    txtDECIMAL_SEPARATOR.Text = SplendidDefaults.DecimalSeparator();
                                                }

                                                // freebusy
                                                // 08/05/2006 Paul.  Remove stub of unsupported code. Calendar Publish Key is not supported at this time.
                                                //txtCALENDAR_PUBLISH_KEY .Text    =               XmlUtil.SelectSingleNode(xml, "calendar_publish_key" );
                                                //txtCALENDAR_PUBLISH_URL .Text    =               XmlUtil.SelectSingleNode(xml, "calendar_publish_url" );
                                                //txtCALENDAR_SEARCH_URL  .Text    =               XmlUtil.SelectSingleNode(xml, "calendar_search_url"  );
                                                // 08/05/2006 Paul.  Remove stub of unsupported code. Reminder is not supported at this time.

                                                /*
                                                 * try
                                                 * {
                                                 *      int nREMINDER_TIME = Sql.ToInteger(XmlUtil.SelectSingleNode(xml, "reminder_time"));
                                                 *      if ( nREMINDER_TIME > 0 )
                                                 *      {
                                                 *              lstREMINDER_TIME.SelectedValue = nREMINDER_TIME.ToString();
                                                 *              chkSHOULD_REMIND.Checked = true;
                                                 *      }
                                                 * }
                                                 * catch(Exception ex)
                                                 * {
                                                 *      SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                                 * }
                                                 */
                                            }
                                            catch (Exception ex)
                                            {
                                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null);
                        this.AppendEditViewFields(m_sMODULE + ".EditAddress", tblAddress, null);
                        this.AppendEditViewFields(m_sMODULE + ".EditMailOptions", tblMailOptions, null);

                        try
                        {
                            lstTHEME.SelectedValue = SplendidDefaults.Theme();
                        }
                        catch (Exception ex)
                        {
                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                        }
                        try
                        {
                            string sDefaultLanguage = Sql.ToString(Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"]);
                            if (Sql.IsEmptyString(sDefaultLanguage))
                            {
                                sDefaultLanguage = "en-US";
                            }
                            lstLANGUAGE.SelectedValue = sDefaultLanguage;
                        }
                        catch (Exception ex)
                        {
                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                        }
                        lstLANGUAGE_Changed(null, null);
                    }
                }
                else
                {
                    // 12/02/2005 Paul.  When validation fails, the header title does not retain its value.  Update manually.
                    ctlModuleHeader.Title = Sql.ToString(ViewState["ctlModuleHeader.Title"]);
                    SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title);
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                ctlEditButtons.ErrorText = ex.Message;
            }
        }
Esempio n. 8
0
 public override void ClearForm()
 {
     lstLANGUAGE_OPTIONS.SelectedValue = L10N.NormalizeCulture("en-US");
 }
Esempio n. 9
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term("Terminology.LBL_LIST_FORM_TITLE"));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            this.Visible = SplendidCRM.Security.IS_ADMIN;
            if (!this.Visible)
            {
                return;
            }

            try
            {
                DbProviderFactory dbf = DbProviderFactories.GetFactory();
                using (IDbConnection con = dbf.CreateConnection())
                {
                    string sSQL;
                    sSQL = "select *                 " + ControlChars.CrLf
                           + "  from vwTERMINOLOGY_List" + ControlChars.CrLf
                           + " where 1 = 1             " + ControlChars.CrLf;
                    using (IDbCommand cmd = con.CreateCommand())
                    {
                        cmd.CommandText = sSQL;
                        // 01/12/2006 Paul.  ctlSearch.LANGUAGE is not working.
                        if (!IsPostBack)
                        {
                            Sql.AppendParameter(cmd, L10N.NormalizeCulture(L10n.NAME), 10, Sql.SqlFilterMode.Exact, "LANG");                             //ctlSearch.LANGUAGE = L10n.NAME;
                        }
                        else
                        {
                            ctlSearch.SqlSearchClause(cmd);
                        }
                        if (ctlSearch.GLOBAL_TERMS)
                        {
                            cmd.CommandText += "   and MODULE_NAME is null" + ControlChars.CrLf;
                        }
                        if (!ctlSearch.INCLUDE_LISTS)
                        {
                            cmd.CommandText += "   and LIST_NAME is null" + ControlChars.CrLf;
                        }

                        if (bDebug)
                        {
                            RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd));
                        }

                        using (DbDataAdapter da = dbf.CreateDataAdapter())
                        {
                            ((IDbDataAdapter)da).SelectCommand = cmd;
                            using (DataTable dt = new DataTable())
                            {
                                da.Fill(dt);
                                vwMain             = dt.DefaultView;
                                grdMain.DataSource = vwMain;
                                if (!IsPostBack)
                                {
                                    // 12/14/2007 Paul.  Only set the default sort if it is not already set.  It may have been set by SearchView.
                                    if (String.IsNullOrEmpty(grdMain.SortColumn))
                                    {
                                        grdMain.SortColumn = "NAME";
                                        grdMain.SortOrder  = "asc";
                                    }
                                    grdMain.ApplySort();
                                    grdMain.DataBind();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                lblError.Text = ex.Message;
            }
            if (!IsPostBack)
            {
                // 06/09/2006 Paul.  Remove data binding in the user controls.  Binding is required, but only do so in the ASPX pages.
                //Page.DataBind();
            }
        }