Пример #1
0
        /// <summary>
        /// if not found, returns a new ContactData object with ID = -1.
        /// </summary>
        /// <returns></returns>
        public static ContactData getCurrentContactData()
        {
            int currentId = PageUtils.getFromForm(CurrentContactIdFormName, -1);

            if (currentId > -1)
            {
                return(ContactData.getContact(currentId));
            }
            return(new ContactData());
        }
Пример #2
0
        private void RenderViewIndividual(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] paramList)
        {
            ContactsDb             db   = new ContactsDb();
            ContactPlaceholderData data = db.getContactPlaceholderData(page, identifier, true);

            int contactId = PageUtils.getFromForm(CurrentContactIdFormName, -1);

            ContactData contactToView = ContactData.getContact(contactId);

            bool canEdit = page.currentUserCanWrite;

            string backUrl = page.Url;

            writer.Write("<p><a href=\"" + backUrl + "\">&#171; back to contact listing</a></p>");
            // -- begin output
            if (canEdit)
            {
                writer.Write(getAddEditContactForm(data, contactToView, page, identifier, langToRenderFor));
            }
            else
            {
                StringBuilder html = new StringBuilder();
                html.Append("<table border=\"0\">");

                string dividerLineHtml = getDividerLineHtml(2);

                html.Append(dividerLineHtml);

                html.Append("<tr>");
                html.Append("<td colspan=\"2\" align=\"center\"><h2>" + StringUtils.JoinNonBlanks(" ", new string[] { contactToView.firstName, contactToView.lastName }) + "</h2></td>");

                html.Append(dividerLineHtml);

                string colspan = "1";

                html.Append("<td>Categories:</td>");
                ContactDataCategory[] allCategories = ContactDataCategory.getAllContactCategories();
                html.Append("<td colspan=\"" + colspan + "\">");
                int cbid = 0;
                foreach (ContactDataCategory cat in allCategories)
                {
                    bool   check = (contactToView.contactCategoryIds.IndexOf(cat.CategoryId) > -1);
                    string cb    = PageUtils.getCheckboxHtml(cat.Title, "category", "category" + cbid.ToString(), cat.CategoryId.ToString(), check);
                    html.Append(cb + "<br />");
                    cbid++;
                } // foreach
                html.Append("</td>");

                html.Append(dividerLineHtml);

                html.Append("<tr>");
                html.Append("<td>Title:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.title + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Organization:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.organizationName + "</td>");
                html.Append("</tr>");

                html.Append(dividerLineHtml);

                html.Append("<tr>");
                html.Append("<td>Address 1:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.address1 + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Address 2:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.address2 + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>City:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.city + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Province/State:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.provinceState + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Postal/Zip Code:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.postalZipCode + "</td>");
                html.Append("</tr>");

                html.Append(dividerLineHtml);

                html.Append("<tr>");
                html.Append("<td>Phone Number 1:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.phoneNumber1 + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Phone Number 2:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.phoneNumber2 + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Fax Number:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.faxNumber + "</td>");
                html.Append("</tr>");

                html.Append("<tr>");
                html.Append("<td>Mobile Number:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + contactToView.mobileNumber + "</td>");
                html.Append("</tr>");

                html.Append(dividerLineHtml);

                string emailDisplay = "";
                if (contactToView.emailAddress.Trim() != "")
                {
                    emailDisplay = "<a href=\"mailto:" + contactToView.SpamEncodedEmailAddress + "\">" + contactToView.SpamEncodedEmailAddress + "</a>";
                }

                html.Append("<tr>");
                html.Append("<td>Email Address:</td>");
                html.Append("<td colspan=\"" + colspan + "\">" + emailDisplay + "</td>");
                html.Append("</tr>");

                html.Append("</table>");

                writer.Write(html.ToString());
            }
        }