Example #1
0
        public static void ChangeFieldRank(Field f, int dir)
        {
            int i = getFieldIndexInParentCollection(f);

            if (i >= 0 && i < f.SectionIDObject.FieldSectionIDs.Count)
            {
                int oldRank = f.Rank;
                if (dir == -1 && i == 0)
                {
                    return;
                }
                if (dir == 1 && i == f.SectionIDObject.FieldSectionIDs.Count - 1)
                {
                    return;
                }
                f.Rank = ((Field)f.SectionIDObject.FieldSectionIDs[i + dir]).Rank;
                ((Field)f.SectionIDObject.FieldSectionIDs[i + dir]).Rank = oldRank;
                SFGlobal.ObjectManager.PersistChanges(f);
                SFGlobal.ObjectManager.PersistChanges(f.SectionIDObject.FieldSectionIDs[i + dir]);
                SFGlobal.ObjectManager.Resync(f);
                SFGlobal.ObjectManager.Resync(f.SectionIDObject.FieldSectionIDs[i + dir]);
                SFGlobal.ObjectManager.Resync(f.SectionIDObject);
            }
            SFGlobal.AlertUser("Changed Field: " + f.Title + " Rank");
        }
Example #2
0
 public static Node GetNode(string nodePath)
 {
     System.Web.HttpContext context = System.Web.HttpContext.Current;
     if (context.Application["nodeRoot"] != null)
     {
         try
         {
             Node n;
             if (SFGlobal.IsUserCMS())
             {
                 n = (Node)context.Application["nodeRoot"];
             }
             else
             {
                 n = (Node)context.Application["nodeRootPublic"];
             }
             System.Collections.ArrayList s = new System.Collections.ArrayList(nodePath.Split('*'));
             return(n.Find(s));
         }
         catch (Exception e)
         {
             throw new Exception("user isn't loaded.", e);
             //return null;
         }
     }
     else
     {
         return(null);
     }
 }
Example #3
0
 public static void RemoveSection(FormSection fs)
 {
     SFGlobal.ObjectManager.MarkForDeletion(fs);
     SFGlobal.ObjectManager.PersistChanges(fs);
     SFGlobal.ObjectManager.Resync(fs.FormObject);
     SFGlobal.AlertUser("Section: " + fs.Title + " Deleted");
 }
Example #4
0
        public static void ChangeSectionRank(FormSection fs, int dir)
        {
            int i = getSectionIndexInParentCollection(fs);

            if (i >= 0 && i < fs.FormObject.FormSections.Count)
            {
                int oldRank = fs.Rank;
                if (dir == -1 && i == 0)
                {
                    return;
                }
                if (dir == 1 && i == fs.FormObject.FormSections.Count - 1)
                {
                    return;
                }
                fs.Rank = ((FormSection)fs.FormObject.FormSections[i + dir]).Rank;
                ((FormSection)fs.FormObject.FormSections[i + dir]).Rank = oldRank;
                SFGlobal.ObjectManager.PersistChanges(fs);
                SFGlobal.ObjectManager.PersistChanges(fs.FormObject.FormSections[i + dir]);
                SFGlobal.ObjectManager.Resync(fs.FormObject);
                SFGlobal.ObjectManager.Resync(fs);
                SFGlobal.ObjectManager.Resync(fs.FormObject.FormSections[i + dir]);
            }
            SFGlobal.AlertUser("Changed Section: " + fs.Title + " rank");
        }
Example #5
0
        public void submit_Click(object sender, System.EventArgs e)
        {
            string u = SFGlobal.SqlCleanString(username.Text);
            string p = Dury.SiteFoundry.Security.Cryptography.AsymmetricEncryption.ComputeHash(password.Text, SFGlobal.EncryptionMethod, SFGlobal.EncryptionSalt);
            //string p = SFGlobal.SqlCleanString(password.Text);

            string userGroup = this.getUserGroup(u, p);

            if (userGroup != null)
            {
                FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, username.Text, DateTime.Now, DateTime.Now.AddMinutes(30), false, userGroup);
                string     encryptedTicket           = FormsAuthentication.Encrypt(authTicket);
                HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                Response.Cookies.Add(authCookie);
                //if (Request.QueryString["RequestedUrl"] == null || Request.QueryString["RequestedUrl"] == "")
                Response.Redirect("admin/default.aspx");
                //else
                //	Response.Redirect(Request.QueryString["RequestedUrl"]);
                //msg.Text = userGroup;
            }
            else
            {
                msg.Text = "login invalid";
            }
        }
Example #6
0
        public static FormSection AddSection(Form f, string title, string description)
        {
            FormSection fs = (FormSection)SFGlobal.ObjectManager.GetObject(typeof(FormSection));

            fs.FormID      = f.FormID;
            fs.Title       = title;
            fs.Description = description;
            fs.Rank        = getSectionNextRank(f);
            SFGlobal.ObjectManager.PersistChanges(fs);
            SFGlobal.ObjectManager.Resync(fs);
            SFGlobal.AlertUser("Section: " + fs.Title + " Added");
            return(fs);
        }
Example #7
0
        public static Field AddFieldToSection(FormSection fs, int fieldType, string title, string groupName, string description, bool isRequired, bool isValidated, string validationExpression)
        {
            Field f = (Field)SFGlobal.ObjectManager.GetObject(typeof(Field));

            f.SectionID            = fs.FormSectionID;
            f.FieldTypeID          = fieldType;
            f.Title                = title;
            f.Description          = description;
            f.GroupName            = groupName;
            f.IsRequired           = isRequired;
            f.IsValidated          = isValidated;
            f.ValidationExpression = validationExpression;
            f.Rank = getFieldNextRank(fs);
            SFGlobal.ObjectManager.PersistChanges(f);
            SFGlobal.ObjectManager.Resync(fs);
            SFGlobal.AlertUser("Field added");
            return(f);
        }
Example #8
0
        /// <summary>
        /// gets a UserPrincipal object.
        /// if a forms-auth cookie exists, then it loads that.  if no cookie is present, then the user is assigned public access
        /// </summary>
        /// <returns></returns>
        public static UserPrincipal FetchUser()
        {
            System.Web.HttpContext context    = System.Web.HttpContext.Current;
            HttpCookie             authCookie = context.Request.Cookies[FormsAuthentication.FormsCookieName];
            int       userID;
            string    username;
            ArrayList userGroups;

            // add default permissions for unauthenticated (ie. non-cookied 'public') user
            if (authCookie == null)
            {
                userGroups = new ArrayList();
                userGroups.Add("Public");
                userID   = 1;
                username = "******";
            }
            else
            {
                FormsAuthenticationTicket authTicket = null;
                try
                {
                    authTicket = FormsAuthentication.Decrypt(authCookie.Value);
                }
                catch (Exception ex)
                {
                    throw new DuryTools.ErrorHandler(ex.Message, ex);
                }
                if (null == authTicket)
                {
                    SFGlobal.RedirectToLogin();
                }
                // array of items from cookie has the userID as the first element (so we remove it).  all other elements are user roles
                userGroups = new ArrayList(authTicket.UserData.Split(new char[] { '|' }));
                userID     = int.Parse(userGroups[0].ToString());
                username   = authTicket.Name;
                userGroups.RemoveAt(0);
            }
            return(SFGlobal.CreateUserPrincipal(userID, username, userGroups));
        }
Example #9
0
 private static void fsw_Changed(object sender, System.IO.FileSystemEventArgs e)
 {
     SFGlobal.Start();
 }
Example #10
0
 public static void SaveForm(Form f)
 {
     SFGlobal.ObjectManager.PersistChanges(f);
     SFGlobal.ObjectManager.Resync(f);
     SFGlobal.AlertUser("Form Saved");
 }
Example #11
0
 public static void RemoveField(Field f)
 {
     SFGlobal.ObjectManager.MarkForDeletion(f);
     SFGlobal.ObjectManager.PersistChanges(f);
     SFGlobal.AlertUser("Field: " + f.Title + " Deleted!");
 }
Example #12
0
 public static void SaveField(Field f)
 {
     SFGlobal.ObjectManager.PersistChanges(f);
     SFGlobal.ObjectManager.Resync(f);
     SFGlobal.AlertUser("Saved Field: " + f.Title);
 }
Example #13
0
 public static void SaveFormSection(FormSection fs)
 {
     SFGlobal.ObjectManager.PersistChanges(fs);
     SFGlobal.ObjectManager.Resync(fs);
     SFGlobal.AlertUser("Section: " + fs.Title + " Saved");
 }