Exemple #1
0
        public ActionResult Index(string id, bool useShell = true)
        {
            var check = (from e in CurrentDatabase.Contents
                         where e.Name == "SGF-" + id + ".xml"
                         select e).SingleOrDefault();

            if (check == null)
            {
                return(new HttpNotFoundResult("Page not found!"));
            }

            var sgfm = BuildSmallGroupFinderModel(id, useShell);

            // Process shell here
            if (sgfm.hasShell())
            {
                var template = sgfm.createFromShell();
                ViewBag.Shell = template;
                return(View("MapShell", sgfm));
            }

            if (CurrentDatabase.Setting("SGF-UseEmbeddedMap"))
            {
                var template = CurrentDatabase.ContentHtml("ShellDefaultSGF", "<!-- CONTAINER -->");
                ViewBag.Shell = template;
                return(View("MapShell", sgfm));
            }

            return(View("Index", sgfm));
        }
Exemple #2
0
        public User CreateAccount()
        {
            //var Db = Db;
            if (!person.EmailAddress.HasValue())
            {
                CannotCreateAccount = true;
            }
            else if (person.Users.Any()) // already have account
            {
                if (org == null || org.IsMissionTrip == true)
                {
                    return(null);
                }

                SawExistingAccount = true;
                var user = person.Users.OrderByDescending(uu => uu.LastActivityDate).First();

                var message = CurrentDatabase.ContentHtml("ExistingUserConfirmation", Resource1.CreateAccount_ExistingUser);
                message = message
                          .Replace("{name}", person.Name)
                          .Replace("{host}", CurrentDatabase.CmsHost);
                Log("AlreadyHaveAccount");
                CurrentDatabase.Email(DbUtil.AdminMail, person, "Account information for " + CurrentDatabase.Host, message);
            }
            else
            {
                CreatedAccount = true;
                var user = MembershipService.CreateUser(CurrentDatabase, person.PeopleId);
                Log("SendNewUserEmail");
                AccountModel.SendNewUserEmail(CurrentDatabase, user.Username);
                return(user);
            }
            return(null);
        }
Exemple #3
0
        public void ProcessReply(string ans)
        {
            var dt = new DateTime(ticks);
            var i  = (from rr in CurrentDatabase.SubRequests
                      where rr.AttendId == attend.AttendId
                      where rr.RequestorId == person.PeopleId
                      where rr.Requested == dt
                      where rr.SubstituteId == sid
                      select rr).Single();

            if (attend.Commitment == AttendCommitmentCode.SubFound || attend.SubRequests.Any(ss => ss.CanSub == true))
            {
                DisplayMessage = "This substitute request has already been covered. Thank you so much for responding.";
                Log("Covered", i.Requested, i.SubstituteId);
                return;
            }
            i.Responded = DateTime.Now;
            if (ans != "yes")
            {
                DisplayMessage = "Thank you for responding";
                i.CanSub       = false;
                Log("Regrets", i.Requested, i.SubstituteId);
                CurrentDatabase.SubmitChanges();
                return;
            }
            i.CanSub = true;
            Attend.MarkRegistered(CurrentDatabase, i.Substitute.PeopleId, attend.MeetingId, AttendCommitmentCode.Substitute);
            attend.Commitment = AttendCommitmentCode.SubFound;
            Log("Claimed", i.Requested, i.SubstituteId);
            CurrentDatabase.SubmitChanges();

            message = CurrentDatabase.ContentHtml("VolunteerSubConfirm", Resource1.VolSubModel_VolunteerSubConfirm);

            var body = message
                       .Replace("{substitute}", i.Substitute.Name)
                       .Replace("{requestor}", i.Requestor.Name)
                       .Replace("{org}", org.OrganizationName)
                       .Replace("{meetingdate}", $"{attend.MeetingDate:MMM d, yyyy}")
                       .Replace("{meetingtime}", $"{attend.MeetingDate:h:mm tt}");

            // on screen message
            DisplayMessage = $"<p>You have been sent the following email at {Util.ObscureEmail(i.Substitute.EmailAddress)}.</p>\n" + body;

            // email confirmation
            CurrentDatabase.Email(i.Requestor.FromEmail, i.Substitute,
                                  "Volunteer Substitute Commitment for " + org.OrganizationName, body);

            // notify requestor and org notifyids
            var list = CurrentDatabase.PeopleFromPidString(org.NotifyIds).ToList();

            list.Insert(0, i.Requestor);
            CurrentDatabase.Email(i.Substitute.FromEmail, list,
                                  "Volunteer Substitute Commitment for " + org.OrganizationName,
                                  $@"
<p>The following email was sent to {i.Substitute.Name}.</p>
<blockquote>
{body}
</blockquote>");
        }
        public ActionResult Index(int id, int?pid)
        {
            var o = OrgContentInfo.Get(id);

            if (o == null)
            {
                return(Content("<h2>Not an Organization</h2>"));
            }

            if (!Util.UserPeopleId.HasValue)
            {
                return(Redirect("/OrgContent/Login/" + id));
            }

            if (o.TryRunPython(pid ?? Util.UserPeopleId.Value))
            {
                return(View("ScriptResults", o));
            }

            var org = CurrentDatabase.LoadOrganizationById(o.OrgId);

            // Try to load a template specific to this org type
            var template = CurrentDatabase.ContentHtml($"OrgContent-{org.OrganizationType?.Description}", null);

            // Try to fall back on a standard template
            if (template == null)
            {
                template = CurrentDatabase.ContentHtml("OrgContent", null);
            }

            if (template != null)
            {
                template = template.Replace("{content}", o.Html ?? string.Empty)
                           .Replace("{location}", org.Location ?? string.Empty)
                           .Replace("{type}", org.OrganizationType?.Description ?? string.Empty)
                           .Replace("{division}", org.Division?.Name ?? string.Empty)
                           .Replace("{campus}", org.Campu?.Description ?? string.Empty)
                           .Replace("{orgid}", org.OrganizationId.ToString())
                           .Replace("{name}", org.OrganizationName ?? string.Empty);

                org.GetOrganizationExtras()
                .ForEach(
                    ev =>
                {
                    template = template.Replace($"{{{ev.Field}}}", ev.Data ?? ev.StrValue ?? string.Empty);
                });

                if (template.Contains("{directory}"))
                {
                    ViewBag.qid = CurrentDatabase.NewOrgFilter(id).QueryId;
                }

                ViewBag.template = template;
                return(View(o));
            }

            return(View(o));
        }
Exemple #5
0
        public void ConfirmReregister()
        {
            var p       = List[0];
            var message = CurrentDatabase.ContentHtml("ReregisterLinkEmail", @"Hi {name},
<p>Here is your <a href=""{url}"">MANAGE REGISTRATION</a> link to manage {orgname}. This link will work only once. Creating an account will allow you to do this again without having to email the link.</p>");

            message = message.Replace("{orgname}", Header).Replace("{org}", Header);

            var Staff = CurrentDatabase.StaffPeopleForOrg(Orgid.Value);

            p.SendOneTimeLink(Staff.First().FromEmail,
                              CurrentDatabase.ServerLink("/OnlineReg/RegisterLink/"), "Manage Your Registration for " + Header, message);
            Log("SendReRegisterLink");
        }
        public ActionResult ForgotUsername(string email)
        {
            TryLoadAlternateShell();
            if (Request.HttpMethod.ToUpper() == "GET")
            {
                return(View());
            }

            if (!Util.ValidEmail(email))
            {
                ModelState.AddModelError("email", "valid email required");
            }

            if (!ModelState.IsValid)
            {
                return(View());
            }

            email = email?.Trim();
            var q = from u in CurrentDatabase.Users
                    where u.Person.EmailAddress == email || u.Person.EmailAddress2 == email
                    where email != "" && email != null
                    select u;

            foreach (var user in q)
            {
                var message = CurrentDatabase.ContentHtml("ForgotUsername", Resource1.AccountController_ForgotUsername);
                message = message.Replace("{name}", user.Name);
                message = message.Replace("{username}", user.Username);
                CurrentDatabase.EmailRedacted(CmsData.DbUtil.AdminMail, user.Person, "touchpoint forgot username", message);
                CurrentDatabase.SubmitChanges();
                CurrentDatabase.EmailRedacted(CmsData.DbUtil.AdminMail,
                                              CMSRoleProvider.provider.GetAdmins(),
                                              $"touchpoint user: {user.Name} forgot username", "no content");
            }
            if (!q.Any())
            {
                CurrentDatabase.EmailRedacted(CmsData.DbUtil.AdminMail,
                                              CMSRoleProvider.provider.GetAdmins(),
                                              $"touchpoint unknown email: {email} forgot username", "no content");
            }

            return(RedirectToAction("RequestUsername"));
        }
Exemple #7
0
        public ActionResult ConfirmSubscriptions(ManageSubsModel m)
        {
            m.UpdateSubscriptions();

            var Staff = CurrentDatabase.StaffPeopleForOrg(m.masterorgid);

            var msg     = CurrentDatabase.ContentHtml("ConfirmSubscriptions", Resource1.ConfirmSubscriptions);
            var orgname = m.Description();

            msg = msg.Replace("{org}", orgname).Replace("{details}", m.Summary);
            CurrentDatabase.Email(Staff.First().FromEmail, m.person, "Subscription Confirmation", msg);

            CurrentDatabase.Email(m.person.FromEmail, Staff, "Subscriptions managed",
                                  $@"{m.person.Name} managed subscriptions to {m.Description()}<br/>{m.Summary}");

            SetHeaders(m.masterorgid);
            m.Log("Confirm");
            return(View("ManageSubscriptions/Confirm", m));
        }
Exemple #8
0
        public void ComposeMessage()
        {
            var dt = DateTime.Now;

            ticks = dt.Ticks;
            var yeslink = $@"<a href=""http://volsublink"" aid=""{attend.AttendId}"" pid=""{person.PeopleId}"" ticks=""{ticks}"" ans=""yes"">
Yes, I can sub for you.</a>";
            var nolink  = $@"<a href=""http://volsublink"" aid=""{attend.AttendId}"" pid=""{person.PeopleId}"" ticks=""{ticks}"" ans=""no"">
Sorry, I cannot sub for you.</a>";

            subject = $"Volunteer substitute request for {org.OrganizationName}";
            message = CurrentDatabase.ContentHtml("VolunteerSubRequest", Resource1.VolSubModel_ComposeMessage_Body);
            message = message.Replace("{org}", org.OrganizationName)
                      .Replace("{meetingdate}", attend.MeetingDate.ToString("dddd, MMM d"))
                      .Replace("{meetingtime}", attend.MeetingDate.ToString("h:mm tt"))
                      .Replace("{yeslink}", yeslink)
                      .Replace("{nolink}", nolink)
                      .Replace("{sendername}", person.Name);
        }
Exemple #9
0
        public ActionResult SaveProgress(OnlineRegModel m)
        {
            m.HistoryAdd("saveprogress");
            if (m.UserPeopleId == null)
            {
                m.UserPeopleId = Util.UserPeopleId;
            }
            m.UpdateDatum();
            var p = m.UserPeopleId.HasValue ? CurrentDatabase.LoadPersonById(m.UserPeopleId.Value) : m.List[0].person;

            if (p == null)
            {
                return(Content("We have not found your record yet, cannot save progress, sorry"));
            }
            if (m.masterorgid == null && m.Orgid == null)
            {
                return(Content("Registration is not far enough along to save, sorry."));
            }

            var msg          = CurrentDatabase.ContentHtml("ContinueRegistrationLink", @"
<p>Hi {first},</p>
<p>Here is the link to continue your registration:</p>
Resume [registration for {orgname}]
").Replace("{orgname}", m.Header);
            var linktext     = Regex.Match(msg, @"(\[(.*)\])", RegexOptions.Singleline).Groups[2].Value;
            var registerlink = EmailReplacements.CreateRegisterLink(m.masterorgid ?? m.Orgid, linktext);

            msg = Regex.Replace(msg, @"(\[.*\])", registerlink, RegexOptions.Singleline);

            var notifyids = CurrentDatabase.NotifyIds((m.masterorg ?? m.org).NotifyIds);

            CurrentDatabase.Email(notifyids[0].FromEmail, p, $"Continue your registration for {m.Header}", msg);

            /* We use Content as an ActionResult instead of Message because we want plain text sent back
             * This is an HttpPost ajax call and will have a SiteLayout wrapping this.
             */
            return(Content(@"
We have saved your progress. An email with a link to finish this registration will come to you shortly.
<input type='hidden' id='SavedProgress' value='true'/>
"));
        }
Exemple #10
0
        public string GetThankYouMessage()
        {
            var def = CurrentDatabase.ContentHtml("OnlineRegThanks", Resource1.OnlineRegModel_ThankYouMessage);

            string msg = null;

            if (masterorg != null)
            {
                var setting1 = new Settings();
                if (settings.ContainsKey(masterorg.OrganizationId))
                {
                    setting1 = settings[masterorg.OrganizationId];
                }

                var setting2 = setting1;
                if (last != null && last.org != null && settings.ContainsKey(last.org.OrganizationId))
                {
                    setting1 = settings[last.org.OrganizationId];
                }

                msg = Util.PickFirst(setting1.ThankYouMessage, setting2.ThankYouMessage, def);
            }
            else
            {
                var setting = new Settings();
                if (settings.ContainsKey(org.OrganizationId))
                {
                    setting = settings[org.OrganizationId];
                }

                msg = Util.PickFirst(setting.ThankYouMessage, def);
            }
            msg = msg.Replace("{org}", Header)
                  .Replace("{email}", Util.ObscureEmail(email))
                  .Replace("{url}", URL)
                  .Replace(WebUtility.UrlEncode("{url}"), URL);
            return(msg);
        }
Exemple #11
0
        public ActionResult Index(string id, bool useShell = true)
        {
            if (id != Request.QueryString["id"])
            {
                var query = HttpUtility.ParseQueryString(Request.QueryString.ToQueryString());
                query["id"] = id;
                var urlFormat = "/SmallGroupFinder/Index?" + query.ToQueryString();
                return(Redirect(urlFormat));
            }

            var check = (from e in CurrentDatabase.Contents
                         where e.Name == $"SGF-{id}.xml"
                         select e).Any();

            if (!check)
            {
                return(new HttpNotFoundResult());
            }

            var sgfm = BuildSmallGroupFinderModel(id, useShell);

            // Process shell here
            if (sgfm.hasShell())
            {
                var template = sgfm.createFromShell();
                ViewBag.Shell = template;
                return(View("MapShell", sgfm));
            }

            if (sgfm.UseNewUi)
            {
                var template = CurrentDatabase.ContentHtml("ShellDefaultSGF", "<!-- CONTAINER -->");
                ViewBag.Shell = template;
                return(View("MapShell", sgfm));
            }

            return(View("Index", sgfm));
        }