* Profile.aspx: * ProfileEdition.cs: Fixes the username modification * Book-next.aspx: pollution * NpgsqlMembershipProvider.cs: xmldoc * NpgsqlProfileProvider.cs: use default values from configuration * NpgsqlUserNameProvider.cs: Fixes the username detection * test-domain-TestAPI.config: profile dates must be returned as DateTime * instdbws.sql: The conversion to a valid .Net DateTime requires a credible date time as source value, the null one is not supported. * style.css: Fixes the new notification style * AccountController.cs: Fixes the profile edition. Now using the anti forgery key at login time * Book.aspx: * LocalizedText.resx: * LocalizedText.fr.resx: * CalendarApi.cs: * GoogleController.cs: * LocalizedText.Designer.cs: * LocalizedText.fr.Designer.cs: WIP booking * HomeController.cs: code prettying * Global.asax.cs: Limits the usage of titles in a route to the blog controller * OAuth2.cs: Profile values may be of type DBNull ... * T.cs: All translated strings will be Html encoded, as expected from an html helper * YavscHelpers.cs: A new method to build a javascript string... * App.master: * AppAdmin.master: Notification.body is now a js string literal * NoLogin.master: sync with the true master * Login.aspx: Permits the anti forgery key usage * Estimate.aspx: refactoring * Web.config: Fixes a later commit on the catalog name space * Web.csproj: An ajax helper to notify * ChangePasswordModel.cs: * RegisterClientModel.cs: A regexp for user name * LoginModel.cs: A regexp for user name and password * Profile.cs: A regexp for user name, and profile usage fixes * UserManager.cs: Checks for username availability before trying to modify it * YavscModel.csproj: `ProfileEdition` class addition * ChangeLog: should not be indexed * ChangeLog: useless here * ValidateAjaxAttribute.cs: Fixes usage of HtmlFieldPrefix * BookQuery.cs: Start, end hour and role are required * OtherWebException.cs: useless
154 lines
4 KiB
C#
154 lines
4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Net.Mail;
|
|
using System.Web;
|
|
using System.Web.Configuration;
|
|
using System.Reflection;
|
|
using System.Resources;
|
|
using Yavsc.Model;
|
|
using Npgsql.Web;
|
|
using Npgsql.Web.Blog;
|
|
using Yavsc.Helpers;
|
|
using Yavsc;
|
|
using System.Web.Mvc;
|
|
using Yavsc.Model.Blogs;
|
|
using System.Web.Security;
|
|
using System.Web.Profile;
|
|
|
|
namespace Yavsc.Controllers
|
|
{
|
|
/// <summary>
|
|
/// Home controller.
|
|
/// </summary>
|
|
public class HomeController : Controller
|
|
{
|
|
// Site name
|
|
private static string name = null;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the site name.
|
|
/// </summary>
|
|
/// <value>The name.</value>
|
|
[Obsolete("Use YavscHelpers.SiteName insteed.")]
|
|
public static string Name {
|
|
get {
|
|
if (name == null)
|
|
name = WebConfigurationManager.AppSettings ["Name"];
|
|
return name;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Lists the referenced assemblies.
|
|
/// </summary>
|
|
/// <returns>The info.</returns>
|
|
public ActionResult AssemblyInfo()
|
|
{
|
|
Assembly[] aslist = {
|
|
GetType ().Assembly,
|
|
typeof(ITCPNpgsqlProvider).Assembly,
|
|
typeof(NpgsqlMembershipProvider).Assembly,
|
|
typeof(NpgsqlContentProvider).Assembly,
|
|
typeof(NpgsqlBlogProvider).Assembly
|
|
};
|
|
|
|
List <AssemblyName> asnlist = new List<AssemblyName> ();
|
|
foreach (Assembly asse in aslist) {
|
|
foreach (AssemblyName an in asse.GetReferencedAssemblies ()) {
|
|
if (asnlist.All(x=> string.Compare(x.Name,an.Name)!=0))
|
|
asnlist.Add (an);
|
|
}
|
|
}
|
|
asnlist.Sort (delegate(AssemblyName x, AssemblyName y) {
|
|
return string.Compare (x.Name, y.Name);
|
|
});
|
|
return View (asnlist.ToArray()) ;
|
|
}
|
|
|
|
private static string owneremail = null;
|
|
/// <summary>
|
|
/// Gets or sets the owner email.
|
|
/// </summary>
|
|
/// <value>The owner email.</value>
|
|
public static string OwnerEmail {
|
|
get {
|
|
if (owneremail == null)
|
|
owneremail = WebConfigurationManager.AppSettings.Get ("OwnerEMail");
|
|
return owneremail;
|
|
}
|
|
set {
|
|
owneremail = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Index this instance.
|
|
/// </summary>
|
|
public ActionResult Index ()
|
|
{
|
|
var anonid = Request.AnonymousID;
|
|
if (Session.IsNewSession) {
|
|
if (!Request.IsAuthenticated) {
|
|
ProfileBase anonymousProfile = ProfileBase.Create(anonid);
|
|
object ac = anonymousProfile.GetPropertyValue ("allowcookies");
|
|
|
|
if (ac is string && ((string)ac)!="true")
|
|
YavscHelpers.Notify (ViewData, LocalizedText.ThisSiteUsesCookies,
|
|
"function(){Yavsc.ajax(\"/Yavsc/AllowCookies\", { id:'"+anonid+"' });}");
|
|
}
|
|
}
|
|
|
|
foreach (string tagname in new string[] {"Accueil","Événements","Mentions légales"})
|
|
{
|
|
TagInfo ti = BlogManager.GetTagInfo (tagname);
|
|
// TODO specialyze BlogEntry creating a PhotoEntry
|
|
ViewData [tagname] = ti;
|
|
}
|
|
return View ();
|
|
}
|
|
/// <summary>
|
|
/// Credits this instance.
|
|
/// </summary>
|
|
public ActionResult Credits ()
|
|
{
|
|
return View ();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Contact the specified email, reason and body.
|
|
/// </summary>
|
|
/// <param name="email">Email.</param>
|
|
/// <param name="reason">Reason.</param>
|
|
/// <param name="body">Body.</param>
|
|
public ActionResult Contact (string email, string reason, string body)
|
|
{
|
|
if (email==null)
|
|
ModelState.AddModelError("email","Enter your email");
|
|
|
|
if (reason==null)
|
|
ModelState.AddModelError("reason","Please, fill in a reason");
|
|
|
|
if (body==null)
|
|
ModelState.AddModelError("body","Please, fill in a body");
|
|
if (!ModelState.IsValid)
|
|
return View ();
|
|
|
|
// requires valid owner and admin email?
|
|
if (OwnerEmail == null)
|
|
throw new Exception ("No site owner!");
|
|
|
|
using (System.Net.Mail.MailMessage msg = new MailMessage(email,OwnerEmail,"[Contact] "+reason,body))
|
|
{
|
|
msg.CC.Add(new MailAddress(YavscHelpers.Admail));
|
|
using (System.Net.Mail.SmtpClient sc = new SmtpClient())
|
|
{
|
|
sc.Send (msg);
|
|
YavscHelpers.Notify(ViewData, LocalizedText.Message_sent);
|
|
return View (new { email=email, reason="", body="" });
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|