// // =============================================================================================== // performs all housekeeping when a thread record is changed (add,mod,del) // =============================================================================================== // public override object Execute(Contensive.BaseClasses.CPBaseClass cp) { //int sourceFormId = 0; //int formId = 0; //int forumId = 0; int threadId = 0; string s = ""; string sql = ""; CPCSBaseClass cs = cp.CSNew(); // threadId = cp.Utils.EncodeInteger( cp.Doc.GetProperty("recordId","")); if (threadId == 0) { // // re count 'threads' in all forums // sql = "select ccforums.id as forumId" + ",(select count(ccforumthreads.id) from ccforumthreads where forumId=ccForums.id) as threadCnt" + ",(select count(p.id) from ccforumPosts p left join ccforumThreads t on t.id=p.threadid where t.forumId=ccforums.id) as postCnt" + ",(select max(p.id) from ccforumPosts p left join ccforumThreads t on t.id=p.threadid where t.forumId=ccforums.id) as lastPostId" + " from ccforums" + ""; } else { // // update forum for thread provided // sql = "select ccforums.id as forumId" + ",(select count(ccforumthreads.id) from ccforumthreads where forumId=ccForums.id) as threadCnt" + ",(select count(p.id) from ccforumPosts p left join ccforumThreads t on t.id=p.threadid where t.forumId=ccforums.id) as postCnt" + ",(select max(p.id) from ccforumPosts p left join ccforumThreads t on t.id=p.threadid where t.forumId=ccforums.id) as lastPostId" + " from ccforums" + " where ccforums.id in (select forumid from ccforumthreads where id=" + threadId + ")" + ""; } // if (cs.OpenSQL2(sql, "", 1000, 1)) { while (cs.OK()) { sql = "update ccforums set threads=" + cs.GetInteger("threadCnt") + ",posts=" + cs.GetInteger("postCnt") + ",lastPostId=" + cs.GetInteger("lastPostId") + " where id=" + cs.GetInteger("forumId"); cp.Db.ExecuteSQL(sql, "", "1", "1", "1"); cs.GoNext(); } } cs.Close(); // return s; }
// // // void loadForm(Contensive.BaseClasses.CPBaseClass cp) { CPCSBaseClass cs = cp.CSNew(); // if (cs.Open("People", "ID=" + cp.User.Id, "", false, "", 1, 1)) { cp.Doc.set_Var("panelAccountFirstName", cs.GetText("firstName")); cp.Doc.set_Var("panelAccountLastName", cs.GetText("lastName")); cp.Doc.set_Var("panelAccountEmail", cs.GetText("email")); cp.Doc.set_Var("panelAccountUsername", cs.GetText("username")); cp.Doc.set_Var("panelAccountPassword", cs.GetText("password")); } cs.Close(); }
// // execute method is the only public // public override object Execute(Contensive.BaseClasses.CPBaseClass cp) { const string forumNotificationBody = "" + "<h2>Forum Notification</h2>" + "<p>The following forums have had changes over the past day.<p>" + ""; string returnHtml = ""; DateTime dateLastEmail; DateTime rightNow = DateTime.Now ; DateTime today = rightNow.Date; DateTime yesterday = today.AddDays(-1); CPCSBaseClass cs = cp.CSNew(); int memberId; bool memberMatch; string sqlCriteria = ""; string forumIdChangedList = ""; int forumId; Hashtable forumNamesRef = new Hashtable(); string emailBody = ""; string sql; string testSrc; int testId = 0; string qs = ""; string forumQs = cp.Site.GetText("forum last display qs", ""); string sqlDateLastEmail = ""; string emailDomain = cp.Site.DomainPrimary; // try { dateLastEmail = cp.Site.GetDate("Forums Notification Last Sent", yesterday.ToString() ); cp.Site.SetProperty("Forums Notification Last Sent", rightNow.ToString()); sqlDateLastEmail = cp.Db.EncodeSQLDate(dateLastEmail); // // verify Forum Notification email // testId = cp.Content.GetRecordID("system email", "Forum Notification"); if (testId == 0) { if (emailDomain.IndexOf(".") < 0) { emailDomain = "kma.net"; } cs.Insert("system Email"); cs.SetField("name", "Forum Notification"); cs.SetField("subject", cp.Site.DomainPrimary + " Daily Forum Updates"); cs.SetField("fromAddress", "ForumNotification@" + emailDomain); cs.SetField("copyFilename", forumNotificationBody); cs.Close(); } // // make a list of forums with changes // sql = "select distinct f.id as forumId,f.name as forumName" + " from ((ccForums f" + " left join ccforumThreads t on t.forumId=f.id)" + " left join ccforumPosts p on p.threadid=t.id)" + " where" + " (t.dateAdded>" + sqlDateLastEmail + ")" + " or(p.dateAdded>" + sqlDateLastEmail + ")" + " order by f.id"; cs.OpenSQL(sql); while (cs.OK()) { forumId = cs.GetInteger("forumId"); testSrc = "," + forumIdChangedList + ","; if (testSrc.IndexOf("," + forumId.ToString() + ",") < 0) { forumIdChangedList += "," + forumId; sqlCriteria += "or(forumId=" + forumId + ")"; forumNamesRef.Add(forumId, cs.GetText("forumName")); } cs.GoNext(); } cs.Close(); // // check for people who want notifications for these forums // if (sqlCriteria != "") { sqlCriteria = "(" + sqlCriteria.Substring(2) + ")"; if (cs.Open("forum notification rules", sqlCriteria, "memberId,forumId", true, "memberId,forumId", 999, 1)) { do { // // send this member a list of forums that changed and are on his list // memberId = cs.GetInteger("memberId"); emailBody = ""; do { memberMatch = (memberId == cs.GetInteger("memberId")); if (memberMatch) { forumId = cs.GetInteger("forumId"); testSrc = "," + forumIdChangedList + ","; if (testSrc.IndexOf("," + forumIdChangedList.ToString() + ",") >= 0) { qs = cp.Utils.ModifyQueryString(forumQs, "forumId", forumId.ToString(), true); emailBody += "<li><a href=\"http://" + cp.Site.DomainPrimary + cp.Site.AppRootPath + cp.Site.PageDefault + "?" + qs + "\">" + forumNamesRef[forumId].ToString() + "</a></li>"; } cs.GoNext(); } } while (cs.OK() && memberMatch); if (emailBody != "") { emailBody = "<ul>" + emailBody + "</ul>"; cp.Email.sendSystem("Forum Notification", emailBody, memberId); } } while (cs.OK()); } } } catch (Exception ex) { errorReport(cp, ex, "execute"); } return returnHtml; }
public override object Execute(Contensive.BaseClasses.CPBaseClass cp) { string s = ""; string username = cp.Doc.get_Var("panelLoginUsername"); string password = cp.Doc.get_Var("panelLoginPassword"); string email = cp.Doc.get_Var("panelLoginEmail"); bool autoLogin = cp.Utils.EncodeBoolean(cp.Doc.get_Var("panelLoginAuto")); string reqEmail = cp.Doc.get_Var("panelEmailEmail"); CPCSBaseClass cs = cp.CSNew(); string login = ""; // if (reqEmail != "") { if (cs.Open("People", "email=" + cp.Db.EncodeSQLText(reqEmail), "", false, "", 1, 1)) { cp.Doc.set_Var("Email Flag", "1"); cp.Email.sendPassword(reqEmail); } else { cp.Doc.set_Var("Email Error Flag", "1"); } cs.Close(); // s = cp.Utils.ExecuteAddon("{37B7EDB3-7BE0-4E89-8012-16F0CDEED218}"); } else { // if (!cp.Utils.EncodeBoolean(cp.Site.GetProperty("ALLOWEMAILLOGIN", ""))) { login = username; } else { login = email; } // if (!cp.User.Login(login, password, autoLogin)) { cp.Doc.set_Var("Error Flag", "1"); s = cp.Utils.ExecuteAddon("{37B7EDB3-7BE0-4E89-8012-16F0CDEED218}"); } } // return s; }
// // =============================================================================================== // performs all housekeeping when a post record is changed (add,mod,del) // =============================================================================================== // public override object Execute(Contensive.BaseClasses.CPBaseClass cp) { //int sourceFormId = 0; //int formId = 0; //int forumId = 0; int threadId = 0; int postId = 0; string s = ""; string sql = ""; CPCSBaseClass cs = cp.CSNew(); // postId = cp.Utils.EncodeInteger(cp.Doc.GetProperty("recordId","")); if ( postId==0 ) { // // re count posts for all threads // sql = "select ccforumThreads.id as threadId" + ",(select count(p.id) from ccforumPosts p where p.threadId=ccforumThreads.id) as postCnt" + ",(select max(p.id) from ccforumPosts p where p.threadId=ccforumThreads.id) as lastPostId" + " from ccforumThreads" + ""; } else { // // recount posts for just the thread effected // sql = "select ccforumThreads.id as threadId" + ",(select count(p.id) from ccforumPosts p where p.threadId=ccforumThreads.id) as postCnt" + ",(select max(p.id) from ccforumPosts p where p.threadId=ccforumThreads.id) as lastPostId" + " from ccforumThreads" + " where ccforumThreads.id in (select threadid from ccforumPosts where id=" + postId + ")" + ""; } if (cs.OpenSQL2(sql, "", 1000, 1)) { threadId = cs.GetInteger("threadId"); while (cs.OK()) { sql = "update ccforumthreads" + " set replyCnt=" + cs.GetInteger("postCnt") + "" + ",lastPostId=" + cs.GetInteger("lastPostId") + "" + " where id=" + cs.GetInteger("threadId"); cp.Db.ExecuteSQL(sql, "", "1", "1", "1"); cs.GoNext(); } if (postId != 0) { // // this only affected one post, so only housekeep one thread // cp.Doc.SetProperty("recordId", threadId.ToString()); } } cs.Close(); // // this effects lastPostId, so housekeep threads also // threadHousekeepClass threadHousekeep = new threadHousekeepClass(); threadHousekeep.Execute(cp); // return s; }
// // =============================================================================================== // execute method is the only public // =============================================================================================== // public override object Execute(Contensive.BaseClasses.CPBaseClass cp) { int sourceFormId = 0; int formId = 0; int forumId = 0; int threadId = 0; string interceptForm; string s = ""; string email = ""; bool isEditing = cp.User.IsEditingAnything; string forceInterceptForm = ""; CPBlockBaseClass block = cp.BlockNew(); string qs = ""; string rqs = ""; string copy = ""; CPCSBaseClass cs = cp.CSNew(); // cp.Site.SetProperty("forum last display qs", cp.Doc.RefreshQueryString); // sourceFormId = cp.Utils.EncodeInteger(cp.Doc.get_Var(rnSourceForm)); // formId = cp.Utils.EncodeInteger(cp.Doc.get_Var(rnFormId)); forumId = cp.Utils.EncodeInteger(cp.Doc.get_Var(rnForumId)); threadId = cp.Utils.EncodeInteger(cp.Doc.get_Var(rnThreadId)); interceptForm = cp.Doc.GetProperty(rnIntercept, ""); if ((forumId == 0) & (threadId != 0)) { cs.OpenSQL("select forumId from ccforumThreads where id=" + threadId); if (cs.OK()) { forumId = cs.GetInteger("forumId"); } else { threadId = 0; } } // //cp.Doc.AddRefreshQueryString(rnFormId, formId.ToString()); cp.Doc.AddRefreshQueryString(rnForumId, forumId.ToString()); cp.Doc.AddRefreshQueryString(rnThreadId, threadId.ToString()); //cp.Doc.AddRefreshQueryString(rnIntercept, interceptForm.ToString()); rqs = cp.Doc.RefreshQueryString; // // handle intercept forms // if (interceptForm != "") { switch (interceptForm) { case "register": if (processRegister(cp)) { cp.Response.Redirect("?" + rqs); } break; case "login": if ( cp.User.Login( cp.Doc.GetProperty("username", ""), cp.Doc.GetProperty("password", ""), false) ) { cp.Response.Redirect("?" + rqs); } break; case "logout": cp.User.Logout(); cp.Response.Redirect("?" + rqs); break; case "password": email = cp.Doc.GetProperty("email", ""); if (email == "") { cp.UserError.Add("You must include an email address to have your username and password sent."); } else { cp.Email.sendPassword(email); } break; } } // // process current form // if (sourceFormId != 0) { switch (sourceFormId) { case formIdProfile: formId = processProfile(cp); break; case formIdNewForum: formId = processNewForum(cp); break; case formIdForumList: formId = processForumList(cp); break; case formIdThreadList: formId = processThreadList(cp); break; case formIdNewThread: formId = processNewThread(cp, forumId); break; case formIdNewPost: formId = processNewPost(cp, threadId); break; default: formId = formIdForumList; break; } } // // determine next form if not set // if (formId == 0) { if ( threadId!=0 ) { formId = formIdPostList; } else if ( forumId != 0 ) { formId = formIdThreadList; } else { formId = formIdForumList ; } } // // Intercept login and register - but leave the formId as-is // forceInterceptForm = cp.Doc.GetProperty("forceInterceptForm",""); if ( forceInterceptForm == "login" ) { s = getLogin(cp, formId, forumId, threadId); } else if (forceInterceptForm == "register") { s = getRegister(cp, formId, forumId, threadId); } else if ( ( (forumId != 0) & !userHasAccess(cp, forumId) ) | ( (!cp.User.IsAuthenticated) & ( (formId == formIdNewThread) | (formId == formIdNewPost) | (formId == formIdNewForum) ) ) ) { // // accessing a forum that is closed and you have no permissions // or accessing a form that requires you to login // if (cp.Utils.EncodeBoolean(cp.Doc.GetProperty("register", ""))) { s = getRegister(cp, formId, forumId, threadId); } else if ( !cp.User.IsAuthenticated ) { s = getLogin(cp, formId, forumId, threadId); } else { block.OpenLayout("forum - not in group page"); s = block.GetHtml(); qs = rqs; qs = cp.Utils.ModifyQueryString(qs, rnFormId , formIdForumList.ToString(), false); qs = cp.Utils.ModifyQueryString(qs, rnForumId, "", false); s = s.Replace("$forumList$", "?" + qs); qs = rqs; qs = cp.Utils.ModifyQueryString(qs, rnIntercept, "logout", true); s = s.Replace("$forumlogin$", "?" + qs); } } else { if ((!cp.User.IsAdmin) && (formId == formIdNewForum)) { // // you must be an administrator for these forms // cp.UserError.Add("You must be an administrator to create a new forum."); formId = formIdForumList; } // // verify form requirements // switch (formId) { case formIdPostList: if (threadId == 0) formId = formIdForumList; break; case formIdThreadList: if (forumId == 0) formId = formIdForumList; break; case formIdNewThread: if (forumId == 0) formId = formIdForumList; break; case formIdNewPost: if (threadId == 0) formId = formIdForumList; break; //default: // s = getForumList(cp, isEditing); // break; } // // get next form // switch (formId) { case formIdProfile: s = getProfile(cp); break; case formIdNewForum: s = getNewForum(cp); break; case formIdPostList: s = getPostList(cp, threadId, isEditing); break; case formIdThreadList: s = getThreadList(cp, forumId, isEditing); break; case formIdNewThread: s = getNewThread(cp, forumId); break; case formIdNewPost: s = getNewPost(cp, threadId); break; default: s = getForumList(cp, isEditing); break; } } // // update login, logout, register buttons // rqs = cp.Doc.RefreshQueryString; block.Load(s); if (!cp.User.IsAuthenticated) { // // not authenticated - block anything marked block // qs = rqs; qs = cp.Utils.ModifyQueryString(qs, "forceInterceptForm", "login", true); copy = "<a class=\"loginLightbox\" href=\"?" + qs + "\">Login</a>"; block.SetOuter(".foButtonLogin", copy); qs = cp.Utils.ModifyQueryString(qs, "forceInterceptForm", "register", true); copy = "<a href=\"?" + qs + "\">Register</a>"; block.SetOuter(".foButtonRegister", copy); block.SetOuter(".foButtonLogout", ""); block.SetOuter(".foButtonProfile", ""); } else { // // authenticated // qs = rqs; qs = cp.Utils.ModifyQueryString(qs, rnIntercept, "logout", true); copy = "<a href=\"?" + qs + "\">Logout</a>"; block.SetOuter(".foButtonLogout", copy); block.SetOuter(".foButtonLogin", ""); block.SetOuter(".foButtonRegister", ""); qs = rqs; qs = cp.Utils.ModifyQueryString(qs, rnFormId, formIdProfile.ToString(), true); copy = "<a href=\"?" + qs + "\">Update/Edit Profile</a>"; block.SetOuter(".foButtonProfile", copy); } s = block.GetHtml(); // // return result // return s; }
public override object Execute(Contensive.BaseClasses.CPBaseClass cp) { bool errFlag = false; string s = ""; string firstName = cp.Doc.GetText("panelRegistrationFirstName"); string lastName = cp.Doc.GetText("panelRegistrationLastName"); string email = cp.Doc.GetText("panelRegistrationEmail"); string username = cp.Doc.GetText("panelRegistrationUsername"); string password = cp.Doc.GetText("panelRegistrationPassword"); bool usernameValid = !cp.Site.GetBoolean("ALLOWEMAILLOGIN", ""); CPCSBaseClass cs = cp.CSNew(); // // check for duplicate in username if account requires username // if (usernameValid) { if (cs.Open("People", "(ID<>" + cp.User.Id + ") and (username="******")", "", false, "", 1, 1)) { errFlag = true; cp.Doc.set_Var("errFlag", "1"); cp.Doc.set_Var("errMessage", "The username requested is not available, please enter an alternate username."); } cs.Close(); } if (!errFlag) { if (cs.Open("People", "(ID<>" + cp.User.Id + ") and (email=" + cp.Db.EncodeSQLText(email) + ")", "", false, "", 1, 1)) { errFlag = true; cp.Doc.set_Var("errFlag", "1"); cp.Doc.set_Var("errMessage", "The email entered is already registered. Please verify you have not already registered or enter an alternate email address."); } cs.Close(); } // if (!errFlag) { if ((cp.User.IsRecognized )&&( !cp.User.IsAuthenticated )) { cp.User.Logout(); } if (cs.Open("People", "ID=" + cp.User.Id, "", false, "", 1, 1)) { cs.SetField("name", firstName + " " + lastName); cs.SetField("firstName", firstName); cs.SetField("lastName", lastName); cs.SetField("email", email); cs.SetField("password", password); if (usernameValid) { cs.SetField("username", username); } } cs.Close(); // // authenticate the user // cp.User.LoginByID(cp.User.Id.ToString() ); // s = ""; } else { s = cp.Utils.ExecuteAddon("{E31F7A5B-FE69-4CF5-BD16-7F368192D956}"); } // return s; }
// // execute method is the only public // public override object Execute(Contensive.BaseClasses.CPBaseClass cp) { string returnHtml = "Hello World"; try { // rqs defined once and passed so when we do ajax integration, the rqs will be passed from // from the ajax call so it can be the rqs of the original page, not the /remoteMethod rqs // you get from cp.doc.RefreshQueryString. // srcFormId - passed from a submitting form. Otherwise 0. // dstFormId - the next for to display. used for links to new pages. Will be over-ridden // by the formProcessing of srcFormId if it is present. // appId - Forms typically save data back to the Db. The 'application' is the table // when the data is saved. // rightNow - the date and time when the page is hit. Set once and passed as argument to // enable a test-mode where the time can be hard-coded. // int srcFormId = cp.Utils.EncodeInteger(cp.Doc.GetProperty(statics.rnSrcFormId, "")); int dstFormId = cp.Utils.EncodeInteger(cp.Doc.GetProperty(statics.rnDstFormId, "")); int appId = cp.Utils.EncodeInteger(cp.Doc.GetProperty(statics.rnAppId, "")); string rqs = cp.Doc.RefreshQueryString; DateTime rightNow = DateTime.Now; CPCSBaseClass cs = cp.CSNew(); adminFramework.pageWithNavClass page = new adminFramework.pageWithNavClass(); blankClass blank = new blankClass(); // //------------------------------------------------------------------------ // add common page elements //------------------------------------------------------------------------ // page.title = "Manager Sample Addon"; page.description = "This is the visual studio c# addon template called Manager Sample. A manager addon is a set of forms that together manage a feature."; // //------------------------------------------------------------------------ // process submitted form //------------------------------------------------------------------------ // if (srcFormId != 0) { switch (srcFormId) { // add a case for each form process needed case statics.formIdBlank: dstFormId = blank.processForm(cp, srcFormId, rqs, rightNow, ref appId); break; } } // //------------------------------------------------------------------------ // add page navigation //------------------------------------------------------------------------ // page.addNav(); page.navCaption = "Home"; page.navLink = "?" + cp.Utils.ModifyQueryString(rqs, statics.rnDstFormId, "0", true); // page.addNav(); page.navCaption = "Blank Form"; page.navLink = "?" + cp.Utils.ModifyQueryString(rqs, statics.rnDstFormId, statics.formIdBlank.ToString(), true); // switch (dstFormId) { case (statics.formIdBlank): page.body = blank.getForm(cp, dstFormId, rqs, rightNow, ref appId); break; default: page.body = "<p>Welcome to the default form.</p>"; break; } // //------------------------------------------------------------------------ // output the page //------------------------------------------------------------------------ // returnHtml = page.getHtml(cp); cp.Doc.AddHeadStyle(page.styleSheet); } catch (Exception ex) { errorReport(cp, ex, "execute"); } return returnHtml; }
public override object Execute(Contensive.BaseClasses.CPBaseClass cp) { bool errFlag = false; string s = ""; string firstName = cp.Doc.get_Var("panelAccountFirstName"); string lastName = cp.Doc.get_Var("panelAccountLastName"); string email = cp.Doc.get_Var("panelAccountEmail"); string username = cp.Doc.get_Var("panelAccountUsername"); string password = cp.Doc.get_Var("panelAccountPassword"); CPCSBaseClass cs = cp.CSNew(); string sql = ""; // if allowEmailLogin -- then ignore username input, it is not valid bool allowEmailLogin = cp.Utils.EncodeBoolean(cp.Site.GetProperty("ALLOWEMAILLOGIN", "")); // // check input // if ((firstName == "") | (lastName == "") | (email == "") | (password == "") | ((username == "") & (!allowEmailLogin))) { // // missing fields // errFlag = true; cp.Doc.set_Var("errFlag", "1"); cp.Doc.set_Var("errMessage", "One or more required fields were empty."); } else { // // check for duplicate in username if account requires username // if (allowEmailLogin) { // // email loging, check email provided against email and username fields // sql = "(ID<>" + cp.User.Id + ")" + "and(" + "(username="******")" + "or(email=" + cp.Db.EncodeSQLText(email) + ")" + ")" + ""; } else { // // check username and email provided against both email and username fields // sql = "(ID<>" + cp.User.Id + ")" + "and(" + "(username="******")" + "or(email=" + cp.Db.EncodeSQLText(email) + ")" + "or(username="******")" + "or(email=" + cp.Db.EncodeSQLText(username) + ")" + ")" + ""; } if (cs.Open("People", sql, "", false, "", 1, 1)) { errFlag = true; cp.Doc.set_Var("errFlag", "1"); cp.Doc.set_Var("errMessage", "The login requested is not available, please enter an alternate username."); } cs.Close(); } // if (!errFlag) { if (cs.Open("People", "ID=" + cp.User.Id, "", false, "", 1, 1)) { cs.SetField("name", firstName + " " + lastName); cs.SetField("firstName", firstName); cs.SetField("lastName", lastName); cs.SetField("email", email); cs.SetField("password", password); if (!allowEmailLogin) { cs.SetField("username", username); } } cs.Close(); cp.Doc.set_Var("acctUpdated", "1"); } // s = cp.Utils.ExecuteAddon("{7A057715-5CDD-4D9F-A12A-5CCB61F93974}"); // return s; }