Merge from booking branch
parent
25906d0227
commit
9a2652739b
@ -1,31 +1,20 @@
|
|||||||
2015-11-04 Paul Schneider <paul@pschneider.fr>
|
2015-11-14 Paul Schneider <paul@pschneider.fr>
|
||||||
|
|
||||||
* NpgsqlBlogProvider.cs: Implements the note
|
* NpgsqlBlogProvider.cs: Bill ranking, and delivering hidden
|
||||||
|
content to owner
|
||||||
|
|
||||||
2015-10-19 Paul Schneider <paul@pschneider.fr>
|
2015-11-11 Paul Schneider <paul@pschneider.fr>
|
||||||
|
|
||||||
* NpgsqlTagInfo.cs: Fixes the photo retreival
|
* NpgsqlBlogProvider.cs: refactoring
|
||||||
|
|
||||||
2015-10-17 Paul Schneider <paul@pschneider.fr>
|
2015-11-06 Paul Schneider <paul@pschneider.fr>
|
||||||
|
|
||||||
* NpgsqlTagInfo.cs:
|
* NpgsqlBlogProvider.cs: refactorisation, to render Tags and
|
||||||
* NpgsqlBlogProvider.cs:
|
Circles on each entry type.
|
||||||
|
Fixes the `Find` Method using the `MatchTag` search flag
|
||||||
|
|
||||||
2015-10-17 Paul Schneider <paul@pschneider.fr>
|
* NpgsqlBlogProvider.csproj: cleanning
|
||||||
|
|
||||||
* NpgsqlTagInfo.cs:
|
* ChangeLog:
|
||||||
* NpgsqlBlogProvider.cs:
|
* NpgsqlTagInfo.cs:
|
||||||
* NpgsqlBlogProvider.csproj:
|
|
||||||
|
|
||||||
2015-10-17 Paul Schneider <paul@pschneider.fr>
|
|
||||||
|
|
||||||
* NpgsqlBlogProvider.cs:
|
|
||||||
|
|
||||||
2015-10-13 Paul Schneider <paul@pschneider.fr>
|
|
||||||
|
|
||||||
* NpgsqlBlogProvider.cs: implements the tag methods on db
|
|
||||||
|
|
||||||
2015-10-10 Paul Schneider <paul@pschneider.fr>
|
|
||||||
|
|
||||||
* NpgsqlBlogProvider.cs:
|
|
||||||
|
|
||||||
|
@ -1,9 +1,19 @@
|
|||||||
2015-10-30 Paul Schneider <paul@pschneider.fr>
|
2015-11-17 Paul Schneider <paul@pschneider.fr>
|
||||||
|
|
||||||
* NpgsqlContentProvider.cs: refactoring: a dedicated name
|
* NpgsqlSkillProvider.cs: User's skills profile object now
|
||||||
space for the catalog
|
implements an `Id` property,
|
||||||
|
in order to be rated, perhaps ranked in a near future. It's
|
||||||
|
implemented as the legay profile id.
|
||||||
|
|
||||||
2015-10-28 Paul Schneider <paul@pschneider.fr>
|
2015-11-17 Paul Schneider <paul@pschneider.fr>
|
||||||
|
|
||||||
* NpgsqlCircleProvider.cs: Restores circles edition
|
* NpgsqlSkillProvider.cs: implements a skill provider
|
||||||
|
|
||||||
|
* NpgsqlContentProvider.csproj: Imports the
|
||||||
|
`NpgsqlSkillProvider` class
|
||||||
|
|
||||||
|
2015-11-08 Paul Schneider <paul@pschneider.fr>
|
||||||
|
|
||||||
|
* ChangeLog: this file should not be maintained as a git
|
||||||
|
respository legacy file
|
||||||
|
|
||||||
|
@ -0,0 +1,157 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using Yavsc.Model.Admin;
|
||||||
|
using Npgsql.Web.Blog;
|
||||||
|
using System.Resources;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Yavsc.Admin
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Data manager.
|
||||||
|
/// </summary>
|
||||||
|
public class DataManager
|
||||||
|
{
|
||||||
|
DataAccess da;
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Yavsc.Admin.DataManager"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="datac">Datac.</param>
|
||||||
|
public DataManager (DataAccess datac)
|
||||||
|
{
|
||||||
|
da = datac;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the backup.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The backup.</returns>
|
||||||
|
public Export CreateBackup ()
|
||||||
|
{
|
||||||
|
Environment.SetEnvironmentVariable("PGPASSWORD", da.Password);
|
||||||
|
string fileName = da.BackupPrefix + "-" + DateTime.Now.ToString ("yyyyMMddhhmmss")+".tar";
|
||||||
|
FileInfo ofi = new FileInfo (fileName);
|
||||||
|
Export e = new Export ();
|
||||||
|
e.FileName = ofi.FullName;
|
||||||
|
/*
|
||||||
|
Exec ("pg_dump", string.Format (
|
||||||
|
"-wb -Z3 -f {0} -Ft -h {1} -U {2} -p {3} {4}",
|
||||||
|
fileName, da.Host, da.Dbuser, da.Port, da.Dbname ),e);
|
||||||
|
*/
|
||||||
|
Exec ("pg_dump", string.Format (
|
||||||
|
"-f {0} -Ft -h {1} -U {2} -p {3} {4}",
|
||||||
|
fileName, da.Host, da.DbUser, da.Port, da.DbName ),e);
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Exec(string name, string args, TaskOutput output)
|
||||||
|
{
|
||||||
|
ProcessStartInfo Pinfo =
|
||||||
|
new ProcessStartInfo (name,args);
|
||||||
|
Pinfo.RedirectStandardError = true;
|
||||||
|
Pinfo.RedirectStandardOutput = true;
|
||||||
|
Pinfo.CreateNoWindow = true;
|
||||||
|
Pinfo.UseShellExecute = false;
|
||||||
|
using (Process p = new Process ()) {
|
||||||
|
p.EnableRaisingEvents = true;
|
||||||
|
p.StartInfo = Pinfo;
|
||||||
|
p.Start ();
|
||||||
|
p.WaitForExit ();
|
||||||
|
output.Error = p.StandardError.ReadToEnd ();
|
||||||
|
output.Message = p.StandardOutput.ReadToEnd ();
|
||||||
|
output.ExitCode = p.ExitCode;
|
||||||
|
p.Close ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Restore the specified fileName and dataOnly.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName">File name.</param>
|
||||||
|
/// <param name="dataOnly">If set to <c>true</c> data only.</param>
|
||||||
|
public TaskOutput Restore (string fileName, bool dataOnly)
|
||||||
|
{
|
||||||
|
Environment.SetEnvironmentVariable("PGPASSWORD", da.Password);
|
||||||
|
var t = new TaskOutput ();
|
||||||
|
Exec ("pg_restore", (dataOnly?"-a ":"")+string.Format (
|
||||||
|
"-1 -Ft -O -h {0} -U {1} -p {2} -d {3} {4}",
|
||||||
|
da.Host, da.DbUser, da.Port, da.DbName, fileName ),t);
|
||||||
|
/*
|
||||||
|
Exec ("pg_restore", (dataOnly?"-a ":"")+string.Format (
|
||||||
|
"-1 -w -Fd -O -h {0} -U {1} -p {2} -d {3} {4}",
|
||||||
|
da.Host, da.Dbuser, da.Port, da.Dbname, fileName ),t);
|
||||||
|
*/
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the db.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The db.</returns>
|
||||||
|
public TaskOutput CreateDb ()
|
||||||
|
{
|
||||||
|
TaskOutput res = new TaskOutput ();
|
||||||
|
|
||||||
|
string sql;
|
||||||
|
try {
|
||||||
|
Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
|
||||||
|
using (Stream sqlStream = a.GetManifestResourceStream("Yavsc.instdbws.sql"))
|
||||||
|
{
|
||||||
|
try { using (StreamReader srdr = new StreamReader (sqlStream)) {
|
||||||
|
sql = srdr.ReadToEnd ();
|
||||||
|
using (var cnx = new Npgsql.NpgsqlConnection (da.ConnectionString)) {
|
||||||
|
using (var cmd = cnx.CreateCommand ()) {
|
||||||
|
cmd.CommandText = sql;
|
||||||
|
cnx.Open();
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
cnx.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} } catch (Exception exg) {
|
||||||
|
res.ExitCode = 1;
|
||||||
|
res.Error =
|
||||||
|
string.Format ("Exception of type {0} occred retrieving the script",
|
||||||
|
exg.GetType ().Name);
|
||||||
|
res.Message = exg.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
res.ExitCode = 1;
|
||||||
|
res.Error =
|
||||||
|
string.Format ("Exception of type {0} occured during the script execution",
|
||||||
|
ex.GetType ().Name);
|
||||||
|
res.Message = ex.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Tags the backup.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The backup.</returns>
|
||||||
|
/// <param name="filename">Filename.</param>
|
||||||
|
/// <param name="tags">Tags.</param>
|
||||||
|
public Export TagBackup (string filename, string [] tags)
|
||||||
|
{
|
||||||
|
/* FileInfo fi = new FileInfo (filename);
|
||||||
|
using (FileStream s = fi.OpenWrite ()) {
|
||||||
|
|
||||||
|
} */
|
||||||
|
throw new NotImplementedException ();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Tags the restore.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The restore.</returns>
|
||||||
|
/// <param name="fileName">File name.</param>
|
||||||
|
public TaskOutput TagRestore (string fileName)
|
||||||
|
{
|
||||||
|
Environment.SetEnvironmentVariable ("PGPASSWORD", da.Password);
|
||||||
|
var t = new TaskOutput ();
|
||||||
|
Exec ("pg_restore", string.Format (
|
||||||
|
"-a -w -Fd -O -h {0} -U {1} -p {2} -d {3} {4}",
|
||||||
|
da.Host, da.DbUser, da.Port, da.DbName, fileName ),t);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace Yavsc.Model.Admin
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Export.
|
||||||
|
/// </summary>
|
||||||
|
public class Export: TaskOutput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Yavsc.Model.Admin.Export"/> class.
|
||||||
|
/// </summary>
|
||||||
|
public Export ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the name of the file.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The name of the file.</value>
|
||||||
|
public string FileName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,55 @@
|
|||||||
|
//
|
||||||
|
// AuthorizationDenied.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// Paul Schneider <paul@pschneider.fr>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2015 GNU GPL
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Web.Http;
|
||||||
|
using System.Web.Profile;
|
||||||
|
using System.Web.Security;
|
||||||
|
using Yavsc.Formatters;
|
||||||
|
using Yavsc.Helpers;
|
||||||
|
using Yavsc.Model;
|
||||||
|
using Yavsc.Model.FrontOffice;
|
||||||
|
using Yavsc.Model.RolesAndMembers;
|
||||||
|
using Yavsc.Model.WorkFlow;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace Yavsc.ApiControllers
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Authorization denied.
|
||||||
|
/// </summary>
|
||||||
|
public class AuthorizationDenied : HttpRequestException {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the Yavsc.ApiControllers.AuthorizationDenied class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="msg">Message.</param>
|
||||||
|
public AuthorizationDenied(string msg) : base(msg)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Security;
|
||||||
|
using System.Web.Http;
|
||||||
|
using Yavsc.Model.WorkFlow;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using Yavsc.Model.FrontOffice;
|
||||||
|
|
||||||
|
namespace Yavsc.ApiControllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Basket controller.
|
||||||
|
/// Maintains a collection of articles
|
||||||
|
/// qualified with name value pairs
|
||||||
|
/// </summary>
|
||||||
|
public class BasketController : ApiController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The wfmgr.
|
||||||
|
/// </summary>
|
||||||
|
protected WorkFlowManager wfmgr = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize the specified controllerContext.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="controllerContext">Controller context.</param>
|
||||||
|
protected override void Initialize (System.Web.Http.Controllers.HttpControllerContext controllerContext)
|
||||||
|
{
|
||||||
|
base.Initialize (controllerContext);
|
||||||
|
wfmgr = new WorkFlowManager ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current basket, creates a new one, if it doesn't exist.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The current basket.</value>
|
||||||
|
protected CommandSet CurrentBasket {
|
||||||
|
get {
|
||||||
|
CommandSet b = wfmgr.GetCommands (Membership.GetUser ().UserName);
|
||||||
|
if (b == null) b = new CommandSet ();
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create the specified basket item using specified command parameters.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cmdParams">Command parameters.</param>
|
||||||
|
[Authorize]
|
||||||
|
public long Create(NameValueCollection cmdParams)
|
||||||
|
{
|
||||||
|
// HttpContext.Current.Request.Files
|
||||||
|
Command cmd = new Command(cmdParams, HttpContext.Current.Request.Files);
|
||||||
|
CurrentBasket.Add (cmd);
|
||||||
|
return cmd.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read the specified basket item.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="itemid">Itemid.</param>
|
||||||
|
[Authorize]
|
||||||
|
Command Read(long itemid){
|
||||||
|
return CurrentBasket[itemid];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update the specified item parameter using the specified value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="itemid">Item identifier.</param>
|
||||||
|
/// <param name="param">Parameter name.</param>
|
||||||
|
/// <param name="value">Value.</param>
|
||||||
|
[Authorize]
|
||||||
|
public void UpdateParam(long itemid, string param, string value)
|
||||||
|
{
|
||||||
|
CurrentBasket [itemid].Parameters [param] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delete the specified item.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="itemid">Item identifier.</param>
|
||||||
|
[Authorize]
|
||||||
|
public void Delete(long itemid)
|
||||||
|
{
|
||||||
|
CurrentBasket.Remove (itemid);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,195 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Web.Http;
|
||||||
|
using System.Web.Profile;
|
||||||
|
using System.Web.Security;
|
||||||
|
using Yavsc.Formatters;
|
||||||
|
using Yavsc.Helpers;
|
||||||
|
using Yavsc.Model;
|
||||||
|
using Yavsc.Model.FrontOffice;
|
||||||
|
using Yavsc.Model.RolesAndMembers;
|
||||||
|
using Yavsc.Model.WorkFlow;
|
||||||
|
using System.IO;
|
||||||
|
using Yavsc.Model.FrontOffice.Catalog;
|
||||||
|
|
||||||
|
namespace Yavsc.ApiControllers
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Front office controller.
|
||||||
|
/// </summary>
|
||||||
|
public class FrontOfficeController : ApiController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The wfmgr.
|
||||||
|
/// </summary>
|
||||||
|
protected WorkFlowManager wfmgr = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize the specified controllerContext.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="controllerContext">Controller context.</param>
|
||||||
|
protected override void Initialize (System.Web.Http.Controllers.HttpControllerContext controllerContext)
|
||||||
|
{
|
||||||
|
base.Initialize (controllerContext);
|
||||||
|
wfmgr = new WorkFlowManager ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Catalog this instance.
|
||||||
|
/// </summary>
|
||||||
|
[AcceptVerbs ("GET")]
|
||||||
|
public Catalog Catalog ()
|
||||||
|
{
|
||||||
|
Catalog c = CatalogManager.GetCatalog ();
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the product categorie.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The product categorie.</returns>
|
||||||
|
/// <param name="brandName">Brand name.</param>
|
||||||
|
/// <param name="prodCategorie">Prod categorie.</param>
|
||||||
|
[AcceptVerbs ("GET")]
|
||||||
|
public ProductCategory GetProductCategorie (string brandName, string prodCategorie)
|
||||||
|
{
|
||||||
|
return CatalogManager.GetCatalog ().GetBrand (brandName).GetProductCategory (prodCategorie);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the estimate.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The estimate.</returns>
|
||||||
|
/// <param name="id">Estimate Id.</param>
|
||||||
|
[Authorize]
|
||||||
|
[HttpGet]
|
||||||
|
public Estimate GetEstimate (long id)
|
||||||
|
{
|
||||||
|
Estimate est = wfmgr.ContentProvider.Get (id);
|
||||||
|
string username = Membership.GetUser ().UserName;
|
||||||
|
if (est.Client != username)
|
||||||
|
if (!Roles.IsUserInRole("Admin"))
|
||||||
|
if (!Roles.IsUserInRole("FrontOffice"))
|
||||||
|
throw new AuthorizationDenied (
|
||||||
|
string.Format (
|
||||||
|
"Auth denied to eid {1} for:{2}",
|
||||||
|
id, username));
|
||||||
|
return est;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the estim tex.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The estim tex.</returns>
|
||||||
|
/// <param name="id">Estimate id.</param>
|
||||||
|
[AcceptVerbs ("GET")]
|
||||||
|
public HttpResponseMessage EstimateToTex (long id)
|
||||||
|
{
|
||||||
|
string texest = estimateToTex (id);
|
||||||
|
if (texest == null)
|
||||||
|
throw new InvalidOperationException (
|
||||||
|
"Not an estimate");
|
||||||
|
HttpResponseMessage result = new HttpResponseMessage () {
|
||||||
|
Content = new ObjectContent (typeof(string),
|
||||||
|
texest,
|
||||||
|
new SimpleFormatter ("text/x-tex"))
|
||||||
|
};
|
||||||
|
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue ("attachment") {
|
||||||
|
FileName = "estimate-" + id.ToString () + ".tex"
|
||||||
|
};
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string estimateToTex (long estimid)
|
||||||
|
{
|
||||||
|
Yavsc.templates.Estim tmpe = new Yavsc.templates.Estim ();
|
||||||
|
Estimate e = wfmgr.GetEstimate (estimid);
|
||||||
|
tmpe.Session = new Dictionary<string,object> ();
|
||||||
|
tmpe.Session.Add ("estim", e);
|
||||||
|
Profile prpro = new Profile (ProfileBase.Create (e.Responsible));
|
||||||
|
if (!prpro.HasBankAccount)
|
||||||
|
throw new TemplateException ("NotBankable:" + e.Responsible);
|
||||||
|
if (!prpro.HasPostalAddress)
|
||||||
|
throw new TemplateException ("NoPostalAddress:" + e.Responsible);
|
||||||
|
|
||||||
|
Profile prcli = new Profile (ProfileBase.Create (e.Client));
|
||||||
|
if (!prcli.IsBillable)
|
||||||
|
throw new TemplateException ("NotBillable:" + e.Client);
|
||||||
|
|
||||||
|
|
||||||
|
tmpe.Session.Add ("from", prpro);
|
||||||
|
tmpe.Session.Add ("to", prcli);
|
||||||
|
tmpe.Session.Add ("efrom", Membership.GetUser (e.Responsible).Email);
|
||||||
|
tmpe.Session.Add ("eto", Membership.GetUser (e.Client).Email);
|
||||||
|
tmpe.Init ();
|
||||||
|
return tmpe.TransformText ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the estimate in pdf format from tex generation.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The to pdf.</returns>
|
||||||
|
/// <param name="id">Estimid.</param>
|
||||||
|
[AcceptVerbs("GET")]
|
||||||
|
public HttpResponseMessage EstimateToPdf (long id)
|
||||||
|
{
|
||||||
|
string texest = null;
|
||||||
|
try {
|
||||||
|
texest = estimateToTex (id);
|
||||||
|
} catch (TemplateException ex) {
|
||||||
|
return new HttpResponseMessage (HttpStatusCode.OK) { Content =
|
||||||
|
new ObjectContent (typeof(string),
|
||||||
|
ex.Message, new ErrorHtmlFormatter (HttpStatusCode.NotAcceptable,
|
||||||
|
LocalizedText.DocTemplateException
|
||||||
|
))
|
||||||
|
};
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return new HttpResponseMessage (HttpStatusCode.OK) { Content =
|
||||||
|
new ObjectContent (typeof(string),
|
||||||
|
ex.Message, new ErrorHtmlFormatter (HttpStatusCode.InternalServerError,
|
||||||
|
LocalizedText.DocTemplateException))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (texest == null)
|
||||||
|
return new HttpResponseMessage (HttpStatusCode.OK) { Content =
|
||||||
|
new ObjectContent (typeof(string), "Not an estimation id:" + id,
|
||||||
|
new ErrorHtmlFormatter (HttpStatusCode.NotFound,
|
||||||
|
LocalizedText.Estimate_not_found))
|
||||||
|
};
|
||||||
|
|
||||||
|
var memPdf = new MemoryStream ();
|
||||||
|
try {
|
||||||
|
new TexToPdfFormatter ().WriteToStream (
|
||||||
|
typeof(string), texest, memPdf,null);
|
||||||
|
}
|
||||||
|
catch (FormatterException ex) {
|
||||||
|
return new HttpResponseMessage (HttpStatusCode.OK) { Content =
|
||||||
|
new ObjectContent (typeof(string), ex.Message+"\n\n"+ex.Output+"\n\n"+ex.Error,
|
||||||
|
new ErrorHtmlFormatter (HttpStatusCode.InternalServerError,
|
||||||
|
LocalizedText.InternalServerError))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = new HttpResponseMessage(HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
Content = new ByteArrayContent(memPdf.GetBuffer())
|
||||||
|
};
|
||||||
|
|
||||||
|
result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue ("attachment") {
|
||||||
|
FileName = String.Format (
|
||||||
|
"Estimation-{0}.pdf",
|
||||||
|
id)
|
||||||
|
};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,94 @@
|
|||||||
|
using System;
|
||||||
|
using System.Web;
|
||||||
|
using System.Text;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using System.Web.Routing;
|
||||||
|
using Yavsc.Model.FrontOffice;
|
||||||
|
using System.Web.Mvc.Html;
|
||||||
|
using Yavsc.Model.FrontOffice.Catalog;
|
||||||
|
|
||||||
|
namespace Yavsc.CatExts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Web catalog extensions.
|
||||||
|
/// </summary>
|
||||||
|
public static class WebCatalogExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Commands the form.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The form.</returns>
|
||||||
|
/// <param name="helper">Helper.</param>
|
||||||
|
/// <param name="pos">Position.</param>
|
||||||
|
/// <param name="atc">Atc.</param>
|
||||||
|
public static string CommandForm(this HtmlHelper<PhysicalProduct> helper, Product pos,string atc="Add to backet") {
|
||||||
|
StringBuilder sb = new StringBuilder ();
|
||||||
|
sb.Append (helper.ValidationSummary ());
|
||||||
|
TagBuilder ft = new TagBuilder ("form");
|
||||||
|
ft.Attributes.Add("action","/FrontOffice/Command");
|
||||||
|
ft.Attributes.Add("method","post");
|
||||||
|
ft.Attributes.Add("enctype","multipart/form-data");
|
||||||
|
TagBuilder fieldset = new TagBuilder ("fieldset");
|
||||||
|
|
||||||
|
TagBuilder legend = new TagBuilder ("legend");
|
||||||
|
legend.SetInnerText (pos.Name);
|
||||||
|
TagBuilder para = new TagBuilder ("p");
|
||||||
|
|
||||||
|
StringBuilder sbfc = new StringBuilder ();
|
||||||
|
if (pos.CommandForm != null)
|
||||||
|
foreach (FormElement e in pos.CommandForm.Items) {
|
||||||
|
sbfc.Append (e.ToHtml ());
|
||||||
|
sbfc.Append ("<br/>\n");
|
||||||
|
}
|
||||||
|
sbfc.Append (
|
||||||
|
string.Format(
|
||||||
|
"<input type=\"submit\" value=\"{0}\"/><br/>\n",
|
||||||
|
atc
|
||||||
|
));
|
||||||
|
|
||||||
|
sbfc.Append (helper.Hidden ("ref", pos.Reference));
|
||||||
|
para.InnerHtml = sbfc.ToString ();
|
||||||
|
fieldset.InnerHtml = legend.ToString ()+"\n"+para.ToString ();
|
||||||
|
ft.InnerHtml = fieldset.ToString ();
|
||||||
|
sb.Append (ft.ToString ());
|
||||||
|
return sb.ToString ();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Commands the form.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The form.</returns>
|
||||||
|
/// <param name="helper">Helper.</param>
|
||||||
|
/// <param name="pos">Position.</param>
|
||||||
|
/// <param name="atc">Atc.</param>
|
||||||
|
public static string CommandForm(this HtmlHelper<Service> helper, Product pos,string atc="Add to backet") {
|
||||||
|
StringBuilder sb = new StringBuilder ();
|
||||||
|
sb.Append (helper.ValidationSummary ());
|
||||||
|
TagBuilder ft = new TagBuilder ("form");
|
||||||
|
ft.Attributes.Add("action","/FrontOffice/Command");
|
||||||
|
ft.Attributes.Add("method","post");
|
||||||
|
ft.Attributes.Add("enctype","multipart/form-data");
|
||||||
|
TagBuilder fieldset = new TagBuilder ("fieldset");
|
||||||
|
|
||||||
|
TagBuilder legend = new TagBuilder ("legend");
|
||||||
|
legend.SetInnerText (pos.Name);
|
||||||
|
TagBuilder para = new TagBuilder ("p");
|
||||||
|
|
||||||
|
StringBuilder sbfc = new StringBuilder ();
|
||||||
|
if (pos.CommandForm != null)
|
||||||
|
foreach (FormElement e in pos.CommandForm.Items) {
|
||||||
|
sbfc.Append (e.ToHtml ());
|
||||||
|
sbfc.Append ("<br/>\n");
|
||||||
|
}
|
||||||
|
sbfc.Append (
|
||||||
|
string.Format(
|
||||||
|
"<input type=\"submit\" value=\"{0}\"/><br/>\n",atc));
|
||||||
|
sbfc.Append (helper.Hidden ("ref", pos.Reference));
|
||||||
|
para.InnerHtml = sbfc.ToString ();
|
||||||
|
fieldset.InnerHtml = legend.ToString ()+"\n"+para.ToString ();
|
||||||
|
ft.InnerHtml = fieldset.ToString ();
|
||||||
|
sb.Append (ft.ToString ());
|
||||||
|
return sb.ToString ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
|||||||
|
2015-11-08 Paul Schneider <paul@pschneider.fr>
|
||||||
|
|
||||||
|
* booking.csproj: Removes the system.Core reference
|
||||||
|
|
@ -0,0 +1,419 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Mail;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Configuration;
|
||||||
|
using System.Web.Profile;
|
||||||
|
using System.Web.Security;
|
||||||
|
using Yavsc;
|
||||||
|
using Yavsc.Model.RolesAndMembers;
|
||||||
|
using Yavsc.Helpers;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using Yavsc.Model.Circles;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.Text;
|
||||||
|
using System.Net;
|
||||||
|
using System.Configuration;
|
||||||
|
using Yavsc.Model;
|
||||||
|
|
||||||
|
namespace Yavsc.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Account controller.
|
||||||
|
/// </summary>
|
||||||
|
public class AccountController : Controller
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Avatar the specified user.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">User.</param>
|
||||||
|
[AcceptVerbs (HttpVerbs.Get)]
|
||||||
|
public ActionResult Avatar (string id)
|
||||||
|
{
|
||||||
|
string avatarLocation = Url.AvatarUrl (id);
|
||||||
|
WebRequest wr = WebRequest.Create (avatarLocation);
|
||||||
|
FileContentResult res;
|
||||||
|
using (WebResponse resp = wr.GetResponse ()) {
|
||||||
|
using (Stream str = resp.GetResponseStream ()) {
|
||||||
|
byte[] content = new byte[str.Length];
|
||||||
|
str.Read (content, 0, (int)str.Length);
|
||||||
|
res = File (content, resp.ContentType);
|
||||||
|
wr.Abort ();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Index this instance.
|
||||||
|
/// </summary>
|
||||||
|
public ActionResult Index ()
|
||||||
|
{
|
||||||
|
return View ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO [ValidateAntiForgeryToken]
|
||||||
|
/// <summary>
|
||||||
|
/// Does login.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The login.</returns>
|
||||||
|
/// <param name="model">Model.</param>
|
||||||
|
/// <param name="returnUrl">Return URL.</param>
|
||||||
|
[HttpPost,ValidateAntiForgeryToken]
|
||||||
|
public ActionResult Login (LoginModel model, string returnUrl)
|
||||||
|
{
|
||||||
|
if (ModelState.IsValid) {
|
||||||
|
if (Membership.ValidateUser (model.UserName, model.Password)) {
|
||||||
|
FormsAuthentication.SetAuthCookie (model.UserName, model.RememberMe);
|
||||||
|
if (returnUrl != null)
|
||||||
|
return Redirect (returnUrl);
|
||||||
|
else
|
||||||
|
return View ("Index");
|
||||||
|
} else {
|
||||||
|
ModelState.AddModelError ("UserName", "The user name or password provided is incorrect.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ViewData ["returnUrl"] = returnUrl;
|
||||||
|
return View (model);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Login the specified returnUrl.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="returnUrl">Return URL.</param>
|
||||||
|
[HttpGet]
|
||||||
|
public ActionResult Login (string returnUrl)
|
||||||
|
{
|
||||||
|
ViewData ["returnUrl"] = returnUrl;
|
||||||
|
return View ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the registration form.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The register.</returns>
|
||||||
|
/// <param name="model">Model.</param>
|
||||||
|
/// <param name="returnUrl">Return URL.</param>
|
||||||
|
public ActionResult GetRegister(RegisterViewModel model, string returnUrl)
|
||||||
|
{
|
||||||
|
ViewData ["returnUrl"] = returnUrl;
|
||||||
|
return View ("Register",model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Register the specified model and returnUrl.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model">Model.</param>
|
||||||
|
/// <param name="returnUrl">Return URL.</param>
|
||||||
|
[HttpPost]
|
||||||
|
public ActionResult Register (RegisterViewModel model, string returnUrl)
|
||||||
|
{
|
||||||
|
ViewData ["returnUrl"] = returnUrl;
|
||||||
|
|
||||||
|
if (ModelState.IsValid) {
|
||||||
|
if (model.ConfirmPassword != model.Password) {
|
||||||
|
ModelState.AddModelError ("ConfirmPassword", "Veuillez confirmer votre mot de passe");
|
||||||
|
return View (model);
|
||||||
|
}
|
||||||
|
|
||||||
|
MembershipCreateStatus mcs;
|
||||||
|
var user = Membership.CreateUser (
|
||||||
|
model.UserName,
|
||||||
|
model.Password,
|
||||||
|
model.Email,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
out mcs);
|
||||||
|
switch (mcs) {
|
||||||
|
case MembershipCreateStatus.DuplicateEmail:
|
||||||
|
ModelState.AddModelError ("Email", "Cette adresse e-mail correspond " +
|
||||||
|
"à un compte utilisateur existant");
|
||||||
|
return View (model);
|
||||||
|
case MembershipCreateStatus.DuplicateUserName:
|
||||||
|
ModelState.AddModelError ("UserName", "Ce nom d'utilisateur est " +
|
||||||
|
"déjà enregistré");
|
||||||
|
return View (model);
|
||||||
|
case MembershipCreateStatus.Success:
|
||||||
|
Url.SendActivationMessage (user);
|
||||||
|
ViewData ["username"] = user.UserName;
|
||||||
|
ViewData ["email"] = user.Email;
|
||||||
|
return View ("RegistrationPending");
|
||||||
|
default:
|
||||||
|
ViewData ["Error"] = "Une erreur inattendue s'est produite" +
|
||||||
|
"a l'enregistrement de votre compte utilisateur" +
|
||||||
|
string.Format ("({0}).", mcs.ToString ()) +
|
||||||
|
"Veuillez pardonner la gêne" +
|
||||||
|
"occasionnée";
|
||||||
|
return View (model);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return View (model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Changes the password success.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The password success.</returns>
|
||||||
|
public ActionResult ChangePasswordSuccess ()
|
||||||
|
{
|
||||||
|
return View ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Changes the password.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The password.</returns>
|
||||||
|
[HttpGet]
|
||||||
|
[Authorize]
|
||||||
|
public ActionResult ChangePassword ()
|
||||||
|
{
|
||||||
|
return View ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unregister the specified id and confirmed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Identifier.</param>
|
||||||
|
/// <param name="confirmed">If set to <c>true</c> confirmed.</param>
|
||||||
|
[Authorize]
|
||||||
|
public ActionResult Unregister (string id, bool confirmed = false)
|
||||||
|
{
|
||||||
|
ViewData ["UserName"] = id;
|
||||||
|
if (!confirmed)
|
||||||
|
return View ();
|
||||||
|
string logged = this.User.Identity.Name;
|
||||||
|
if (logged != id)
|
||||||
|
if (!Roles.IsUserInRole ("Admin"))
|
||||||
|
throw new Exception ("Unregister another user");
|
||||||
|
|
||||||
|
Membership.DeleteUser (
|
||||||
|
Membership.GetUser ().UserName);
|
||||||
|
return RedirectToAction ("Index", "Home");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Changes the password.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The password.</returns>
|
||||||
|
/// <param name="model">Model.</param>
|
||||||
|
[Authorize]
|
||||||
|
[HttpPost]
|
||||||
|
public ActionResult ChangePassword (ChangePasswordModel model)
|
||||||
|
{
|
||||||
|
if (ModelState.IsValid) {
|
||||||
|
|
||||||
|
// ChangePassword will throw an exception rather
|
||||||
|
// than return false in certain failure scenarios.
|
||||||
|
bool changePasswordSucceeded = false;
|
||||||
|
try {
|
||||||
|
MembershipUserCollection users =
|
||||||
|
Membership.FindUsersByName (model.Username);
|
||||||
|
if (users.Count > 0) {
|
||||||
|
MembershipUser user = Membership.GetUser (model.Username, true);
|
||||||
|
|
||||||
|
changePasswordSucceeded = user.ChangePassword (model.OldPassword, model.NewPassword);
|
||||||
|
} else {
|
||||||
|
changePasswordSucceeded = false;
|
||||||
|
ModelState.AddModelError ("Username", "The user name not found.");
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ViewData ["Error"] = ex.ToString ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changePasswordSucceeded) {
|
||||||
|
return RedirectToAction ("ChangePasswordSuccess");
|
||||||
|
} else {
|
||||||
|
ModelState.AddModelError ("Password", "The current password is incorrect or the new password is invalid.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we got this far, something failed, redisplay form
|
||||||
|
return View (model);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Profile the specified id.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Identifier.</param>
|
||||||
|
[Authorize]
|
||||||
|
[HttpGet]
|
||||||
|
public ActionResult Profile (string id)
|
||||||
|
{
|
||||||
|
if (id == null)
|
||||||
|
id = Membership.GetUser ().UserName;
|
||||||
|
ViewData ["UserName"] = id;
|
||||||
|
ProfileEdition model = new ProfileEdition (ProfileBase.Create (id));
|
||||||
|
model.RememberMe = FormsAuthentication.GetAuthCookie (id, true) == null;
|
||||||
|
return View (model);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Profile the specified id, model and AvatarFile.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Identifier.</param>
|
||||||
|
/// <param name="model">Model.</param>
|
||||||
|
/// <param name="AvatarFile">Avatar file.</param>
|
||||||
|
[Authorize]
|
||||||
|
[HttpPost]
|
||||||
|
public ActionResult Profile (string id, ProfileEdition model, HttpPostedFileBase AvatarFile)
|
||||||
|
{
|
||||||
|
string logdu = User.Identity.Name;
|
||||||
|
if (string.IsNullOrWhiteSpace (id)) {
|
||||||
|
if (string.IsNullOrWhiteSpace (model.UserName)) {
|
||||||
|
model.UserName = logdu;
|
||||||
|
return View (model);
|
||||||
|
} else {
|
||||||
|
id = logdu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ViewData ["UserName"] = id;
|
||||||
|
bool editsTheUserName = model.NewUserName!=null&&(string.Compare(id,model.NewUserName)!=0);
|
||||||
|
// Checks authorisation
|
||||||
|
if (logdu!=id)
|
||||||
|
if (!Roles.IsUserInRole ("Admin"))
|
||||||
|
if (!Roles.IsUserInRole ("FrontOffice"))
|
||||||
|
throw new UnauthorizedAccessException ("Your are not authorized to modify this profile");
|
||||||
|
// checks availability of a new username
|
||||||
|
if (editsTheUserName)
|
||||||
|
if (!UserManager.IsAvailable (model.NewUserName))
|
||||||
|
ModelState.AddModelError ("UserName",
|
||||||
|
string.Format (
|
||||||
|
LocalizedText.DuplicateUserName,
|
||||||
|
model.NewUserName
|
||||||
|
));
|
||||||
|
if (AvatarFile != null) {
|
||||||
|
// if said valid, move as avatar file
|
||||||
|
// else invalidate the model
|
||||||
|
if (AvatarFile.ContentType == "image/png") {
|
||||||
|
string avdir = Server.MapPath (YavscHelpers.AvatarDir);
|
||||||
|
var di = new DirectoryInfo (avdir);
|
||||||
|
if (!di.Exists)
|
||||||
|
di.Create ();
|
||||||
|
string avpath = Path.Combine (avdir, id + ".png");
|
||||||
|
AvatarFile.SaveAs (avpath);
|
||||||
|
model.avatar = Url.Content( YavscHelpers.AvatarDir + "/" + id + ".png");
|
||||||
|
} else
|
||||||
|
ModelState.AddModelError ("Avatar",
|
||||||
|
string.Format ("Image type {0} is not supported (suported formats : {1})",
|
||||||
|
AvatarFile.ContentType, "image/png"));
|
||||||
|
}
|
||||||
|
if (ModelState.IsValid) {
|
||||||
|
ProfileBase prf = ProfileBase .Create (id);
|
||||||
|
prf.SetPropertyValue ("Name", model.Name);
|
||||||
|
prf.SetPropertyValue ("BlogVisible", model.BlogVisible);
|
||||||
|
prf.SetPropertyValue ("BlogTitle", model.BlogTitle);
|
||||||
|
if (AvatarFile != null) {
|
||||||
|
prf.SetPropertyValue ("Avatar", model.avatar);
|
||||||
|
} else {
|
||||||
|
var av = prf.GetPropertyValue ("Avatar");
|
||||||
|
if (av != null)
|
||||||
|
model.avatar = av as string;
|
||||||
|
}
|
||||||
|
prf.SetPropertyValue ("Address", model.Address);
|
||||||
|
prf.SetPropertyValue ("CityAndState", model.CityAndState);
|
||||||
|
prf.SetPropertyValue ("Country", model.Country);
|
||||||
|
prf.SetPropertyValue ("ZipCode", model.ZipCode);
|
||||||
|
prf.SetPropertyValue ("WebSite", model.WebSite);
|
||||||
|
prf.SetPropertyValue ("Name", model.Name);
|
||||||
|
prf.SetPropertyValue ("Phone", model.Phone);
|
||||||
|
prf.SetPropertyValue ("Mobile", model.Mobile);
|
||||||
|
prf.SetPropertyValue ("BankCode", model.BankCode);
|
||||||
|
prf.SetPropertyValue ("IBAN", model.IBAN);
|
||||||
|
prf.SetPropertyValue ("BIC", model.BIC);
|
||||||
|
prf.SetPropertyValue ("WicketCode", model.WicketCode);
|
||||||
|
prf.SetPropertyValue ("AccountNumber", model.AccountNumber);
|
||||||
|
prf.SetPropertyValue ("BankedKey", model.BankedKey);
|
||||||
|
prf.SetPropertyValue ("gcalid", model.GoogleCalendar);
|
||||||
|
prf.Save ();
|
||||||
|
|
||||||
|
if (editsTheUserName) {
|
||||||
|
UserManager.ChangeName (id, model.NewUserName);
|
||||||
|
FormsAuthentication.SetAuthCookie (model.NewUserName, model.RememberMe);
|
||||||
|
model.UserName = model.NewUserName;
|
||||||
|
}
|
||||||
|
YavscHelpers.Notify(ViewData, "Profile enregistré"+((editsTheUserName)?", nom public inclu.":""));
|
||||||
|
}
|
||||||
|
return View (model);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Circles this instance.
|
||||||
|
/// </summary>
|
||||||
|
[Authorize]
|
||||||
|
public ActionResult Circles ()
|
||||||
|
{
|
||||||
|
string user = Membership.GetUser ().UserName;
|
||||||
|
ViewData["Circles"] = CircleManager.DefaultProvider.List (user);
|
||||||
|
return View ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Logout the specified returnUrl.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="returnUrl">Return URL.</param>
|
||||||
|
[Authorize]
|
||||||
|
public ActionResult Logout (string returnUrl)
|
||||||
|
{
|
||||||
|
FormsAuthentication.SignOut ();
|
||||||
|
return Redirect (returnUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Losts the password.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The password.</returns>
|
||||||
|
/// <param name="model">Model.</param>
|
||||||
|
public ActionResult ResetPassword(LostPasswordModel model)
|
||||||
|
{
|
||||||
|
if (Request.HttpMethod == "POST") {
|
||||||
|
StringDictionary errors;
|
||||||
|
MembershipUser user;
|
||||||
|
YavscHelpers.ValidatePasswordReset (model, out errors, out user);
|
||||||
|
foreach (string key in errors.Keys)
|
||||||
|
ModelState.AddModelError (key, errors [key]);
|
||||||
|
|
||||||
|
if (user != null && ModelState.IsValid)
|
||||||
|
Url.SendActivationMessage (user);
|
||||||
|
}
|
||||||
|
return View (model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Validate the specified id and key.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Identifier.</param>
|
||||||
|
/// <param name="key">Key.</param>
|
||||||
|
[HttpGet]
|
||||||
|
public ActionResult Validate (string id, string key)
|
||||||
|
{
|
||||||
|
MembershipUser u = Membership.GetUser (id, false);
|
||||||
|
if (u == null) {
|
||||||
|
YavscHelpers.Notify( ViewData,
|
||||||
|
string.Format ("Cet utilisateur n'existe pas ({0})", id));
|
||||||
|
} else if (u.ProviderUserKey.ToString () == key) {
|
||||||
|
if (u.IsApproved) {
|
||||||
|
YavscHelpers.Notify( ViewData,
|
||||||
|
string.Format ("Votre compte ({0}) est déjà validé.", id));
|
||||||
|
} else {
|
||||||
|
u.IsApproved = true;
|
||||||
|
Membership.UpdateUser (u);
|
||||||
|
YavscHelpers.Notify( ViewData,
|
||||||
|
string.Format ("La création de votre compte ({0}) est validée.", id));
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
YavscHelpers.Notify( ViewData, "La clé utilisée pour valider ce compte est incorrecte" );
|
||||||
|
return View ();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using Yavsc.Admin;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Yavsc.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Back office controller.
|
||||||
|
/// </summary>
|
||||||
|
public class BackOfficeController : Controller
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Index this instance.
|
||||||
|
/// </summary>
|
||||||
|
[Authorize(Roles="Admin,Providers")]
|
||||||
|
public ActionResult Index()
|
||||||
|
{
|
||||||
|
return View ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,412 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Mime;
|
||||||
|
using System.Runtime.Serialization.Formatters.Binary;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Configuration;
|
||||||
|
using System.Web.Profile;
|
||||||
|
using System.Web.Security;
|
||||||
|
using Npgsql.Web.Blog;
|
||||||
|
using Yavsc;
|
||||||
|
using Yavsc.Model;
|
||||||
|
using Yavsc.Model.Blogs;
|
||||||
|
using Yavsc.ApiControllers;
|
||||||
|
using Yavsc.Model.RolesAndMembers;
|
||||||
|
using System.Net;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using Yavsc.Model.Circles;
|
||||||
|
using Yavsc.Helpers;
|
||||||
|
|
||||||
|
namespace Yavsc.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Blogs controller.
|
||||||
|
/// </summary>
|
||||||
|
public class BlogsController : Controller
|
||||||
|
{
|
||||||
|
private string sitename =
|
||||||
|
WebConfigurationManager.AppSettings ["Name"];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Index the specified title, pageIndex and pageSize.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="title">Title.</param>
|
||||||
|
/// <param name="pageIndex">Page index.</param>
|
||||||
|
/// <param name="pageSize">Page size.</param>
|
||||||
|
public ActionResult Index (string title, int pageIndex = 0, int pageSize = 10)
|
||||||
|
{
|
||||||
|
if (title != null)
|
||||||
|
return Title (title, pageIndex, pageSize);
|
||||||
|
|
||||||
|
return BlogList (pageIndex, pageSize);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Chooses the media.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The media.</returns>
|
||||||
|
/// <param name="id">Identifier.</param>
|
||||||
|
public ActionResult ChooseMedia(long postid)
|
||||||
|
{
|
||||||
|
return View ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Blogs the list.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The list.</returns>
|
||||||
|
/// <param name="pageIndex">Page index.</param>
|
||||||
|
/// <param name="pageSize">Page size.</param>
|
||||||
|
public ActionResult BlogList (int pageIndex = 0, int pageSize = 10)
|
||||||
|
{
|
||||||
|
int totalRecords;
|
||||||
|
var bs = BlogManager.LastPosts (pageIndex, pageSize, out totalRecords);
|
||||||
|
ViewData ["ResultCount"] = totalRecords;
|
||||||
|
ViewData ["PageSize"] = pageSize;
|
||||||
|
ViewData ["PageIndex"] = pageIndex;
|
||||||
|
var bec = new BlogEntryCollection (bs);
|
||||||
|
return View ("Index", bec );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Title the specified title, pageIndex and pageSize.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Title.</param>
|
||||||
|
/// <param name="pageIndex">Page index.</param>
|
||||||
|
/// <param name="pageSize">Page size.</param>
|
||||||
|
///
|
||||||
|
[HttpGet]
|
||||||
|
public ActionResult Title (string title, int pageIndex = 0, int pageSize = 10)
|
||||||
|
{
|
||||||
|
int recordCount;
|
||||||
|
MembershipUser u = Membership.GetUser ();
|
||||||
|
string username = u == null ? null : u.UserName;
|
||||||
|
FindBlogEntryFlags sf = FindBlogEntryFlags.MatchTitle;
|
||||||
|
BlogEntryCollection c =
|
||||||
|
BlogManager.FindPost (username, title, sf, pageIndex, pageSize, out recordCount);
|
||||||
|
var utc = new UTBlogEntryCollection (title);
|
||||||
|
utc.AddRange (c);
|
||||||
|
ViewData ["RecordCount"] = recordCount;
|
||||||
|
ViewData ["PageIndex"] = pageIndex;
|
||||||
|
ViewData ["PageSize"] = pageSize;
|
||||||
|
return View ("Title", utc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Users the posts.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The posts.</returns>
|
||||||
|
/// <param name="user">User.</param>
|
||||||
|
/// <param name="pageIndex">Page index.</param>
|
||||||
|
/// <param name="pageSize">Page size.</param>
|
||||||
|
[HttpGet]
|
||||||
|
public ActionResult UserPosts (string user, string title=null, int pageIndex = 0, int pageSize = 10)
|
||||||
|
{
|
||||||
|
if (title != null) return UserPost (user, title, pageIndex, pageSize);
|
||||||
|
int recordcount=0;
|
||||||
|
MembershipUser u = Membership.GetUser ();
|
||||||
|
FindBlogEntryFlags sf = FindBlogEntryFlags.MatchUserName;
|
||||||
|
ViewData ["SiteName"] = sitename;
|
||||||
|
ViewData ["BlogUser"] = user;
|
||||||
|
string readersName = null;
|
||||||
|
ViewData ["PageIndex"] = pageIndex;
|
||||||
|
ViewData ["pageSize"] = pageSize;
|
||||||
|
// displays invisible items when the logged user is also the author
|
||||||
|
if (u != null) {
|
||||||
|
if (u.UserName == user || Roles.IsUserInRole ("Admin"))
|
||||||
|
sf |= FindBlogEntryFlags.MatchInvisible;
|
||||||
|
readersName = u.UserName;
|
||||||
|
if (user == null)
|
||||||
|
user = u.UserName;
|
||||||
|
}
|
||||||
|
// find entries
|
||||||
|
BlogEntryCollection c =
|
||||||
|
BlogManager.FindPost (readersName, user, sf, pageIndex, pageSize, out recordcount);
|
||||||
|
// Get author's meta data
|
||||||
|
var pr = ProfileBase.Create (user);
|
||||||
|
if (pr != null) {
|
||||||
|
Profile bupr = new Profile (pr);
|
||||||
|
ViewData ["BlogUserProfile"] = bupr;
|
||||||
|
|
||||||
|
// Inform of listing meta data
|
||||||
|
ViewData ["BlogTitle"] = bupr.BlogTitle;
|
||||||
|
ViewData ["Avatar"] = bupr.avatar;
|
||||||
|
}
|
||||||
|
ViewData ["RecordCount"] = recordcount;
|
||||||
|
UUBlogEntryCollection uuc = new UUBlogEntryCollection (user, c);
|
||||||
|
return View ("UserPosts", uuc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the comment.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The comment.</returns>
|
||||||
|
/// <param name="cmtid">Cmtid.</param>
|
||||||
|
[Authorize(Roles="Blogger")]
|
||||||
|
public ActionResult RemoveComment (long cmtid)
|
||||||
|
{
|
||||||
|
long postid = BlogManager.RemoveComment (cmtid);
|
||||||
|
return GetPost (postid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the post.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The post.</returns>
|
||||||
|
/// <param name="postid">Postid.</param>
|
||||||
|
public ActionResult GetPost (long postid)
|
||||||
|
{
|
||||||
|
ViewData ["id"] = postid;
|
||||||
|
BlogEntry e = BlogManager.GetForReading (postid);
|
||||||
|
UUTBlogEntryCollection c = new UUTBlogEntryCollection (e.Author,e.Title);
|
||||||
|
c.Add (e);
|
||||||
|
ViewData ["user"] = c.Author;
|
||||||
|
ViewData ["title"] = c.Title;
|
||||||
|
Profile pr = new Profile (ProfileBase.Create (c.Author));
|
||||||
|
if (pr == null)
|
||||||
|
// the owner's profile must exist
|
||||||
|
// in order to publish its bills
|
||||||
|
return View ("NotAuthorized");
|
||||||
|
ViewData ["BlogUserProfile"] = pr;
|
||||||
|
ViewData ["Avatar"] = pr.avatar;
|
||||||
|
ViewData ["BlogTitle"] = pr.BlogTitle;
|
||||||
|
return View ("UserPost",c);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Users the post.
|
||||||
|
/// Assume that :
|
||||||
|
/// * bec.Count > O
|
||||||
|
/// * bec.All(x=>x.Author == bec[0].Author) ;
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The post.</returns>
|
||||||
|
/// <param name="bec">Bec.</param>
|
||||||
|
private ActionResult UserPost (UUTBlogEntryCollection bec)
|
||||||
|
{
|
||||||
|
if (ModelState.IsValid)
|
||||||
|
if (bec.Count > 0) {
|
||||||
|
Profile pr = new Profile (ProfileBase.Create (bec.Author));
|
||||||
|
if (pr == null)
|
||||||
|
// the owner's profile must exist
|
||||||
|
// in order to publish its bills
|
||||||
|
// This should'nt occur, as long as
|
||||||
|
// a profile must exist for each one of
|
||||||
|
// existing user record in data base
|
||||||
|
// and each post is deleted with user deletion
|
||||||
|
// a post => an author => a profile
|
||||||
|
throw new Exception("Unexpected error retreiving author's profile");
|
||||||
|
ViewData ["BlogUserProfile"] = pr;
|
||||||
|
ViewData ["Avatar"] = pr.avatar;
|
||||||
|
ViewData ["BlogTitle"] = pr.BlogTitle;
|
||||||
|
MembershipUser u = Membership.GetUser ();
|
||||||
|
|
||||||
|
ViewData ["Author"] = bec.Author;
|
||||||
|
if (!pr.BlogVisible) {
|
||||||
|
// only deliver to admins or owner
|
||||||
|
if (u == null)
|
||||||
|
return View ("NotAuthorized");
|
||||||
|
else {
|
||||||
|
if (u.UserName != bec.Author)
|
||||||
|
if (!Roles.IsUserInRole (u.UserName, "Admin"))
|
||||||
|
return View ("NotAuthorized");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (u == null || (u.UserName != bec.Author) && !Roles.IsUserInRole (u.UserName, "Admin")) {
|
||||||
|
// Filer on allowed posts
|
||||||
|
BlogEntryCollection filtered = bec.FilterFor((u == null)?null : u.UserName);
|
||||||
|
UUTBlogEntryCollection nbec = new UUTBlogEntryCollection (bec.Author, bec.Title);
|
||||||
|
nbec.AddRange (filtered);
|
||||||
|
View ("UserPost",nbec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return View ("UserPost",bec);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Users the post.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The post.</returns>
|
||||||
|
/// <param name="user">User.</param>
|
||||||
|
/// <param name="title">Title.</param>
|
||||||
|
/// <param name="pageIndex">Page index.</param>
|
||||||
|
/// <param name="pageSize">Page size.</param>
|
||||||
|
public ActionResult UserPost (string user, string title, int pageIndex = 0, int pageSize = 10)
|
||||||
|
{
|
||||||
|
ViewData ["user"] = user;
|
||||||
|
ViewData ["title"] = title;
|
||||||
|
ViewData ["PageIndex"] = pageIndex;
|
||||||
|
ViewData ["pageSize"] = pageSize;
|
||||||
|
var pb = ProfileBase.Create (user);
|
||||||
|
if (pb == null)
|
||||||
|
// the owner's profile must exist
|
||||||
|
// in order to publish its bills
|
||||||
|
return View ("NotAuthorized");
|
||||||
|
Profile pr = new Profile (pb);
|
||||||
|
ViewData ["BlogUserProfile"] = pr;
|
||||||
|
ViewData ["Avatar"] = pr.avatar;
|
||||||
|
ViewData ["BlogTitle"] = pr.BlogTitle;
|
||||||
|
UUTBlogEntryCollection c = new UUTBlogEntryCollection (user, title);
|
||||||
|
c.AddRange ( BlogManager.FilterOnReadAccess (BlogManager.GetPost (user, title)));
|
||||||
|
return View ("UserPost",c);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Post the specified title.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="title">Title.</param>
|
||||||
|
[Authorize(Roles="Blogger")]
|
||||||
|
public ActionResult Post (string title)
|
||||||
|
{
|
||||||
|
string un = Membership.GetUser ().UserName;
|
||||||
|
if (String.IsNullOrEmpty (title))
|
||||||
|
title = "";
|
||||||
|
ViewData ["SiteName"] = sitename;
|
||||||
|
ViewData ["Author"] = un;
|
||||||
|
ViewData ["AllowedCircles"] = CircleManager.DefaultProvider.List (un)
|
||||||
|
.Select (x => new SelectListItem {
|
||||||
|
Value = x.Id.ToString(),
|
||||||
|
Text = x.Title
|
||||||
|
});
|
||||||
|
|
||||||
|
return View ("Edit", new BlogEntry { Title = title, Author = un });
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Validates the edit.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The edit.</returns>
|
||||||
|
/// <param name="model">Model.</param>
|
||||||
|
[Authorize(Roles="Blogger")]
|
||||||
|
public ActionResult ValidateEdit (BlogEntry model)
|
||||||
|
{
|
||||||
|
ViewData ["SiteName"] = sitename;
|
||||||
|
ViewData ["Author"] = Membership.GetUser ().UserName;
|
||||||
|
if (ModelState.IsValid) {
|
||||||
|
if (model.Id != 0) {
|
||||||
|
// ensures rights to update
|
||||||
|
BlogManager.GetForEditing (model.Id, true);
|
||||||
|
BlogManager.UpdatePost (model.Id, model.Title, model.Content, model.Visible, model.AllowedCircles);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
model.Id = BlogManager.Post (model.Author, model.Title, model.Content, model.Visible, model.AllowedCircles);
|
||||||
|
if (model.Photo != null)
|
||||||
|
BlogManager.UpdatePostPhoto (model.Id, model.Photo);
|
||||||
|
return RedirectToAction ("Title", new { title = model.Title });
|
||||||
|
}
|
||||||
|
ViewData ["AllowedCircles"] =
|
||||||
|
CircleManager.DefaultProvider.List (
|
||||||
|
Membership.GetUser ().UserName).Select (x => new SelectListItem {
|
||||||
|
Value = x.Id.ToString(),
|
||||||
|
Text = x.Title,
|
||||||
|
Selected = model.AllowedCircles.Contains (x.Id)
|
||||||
|
});
|
||||||
|
return View ("Edit", model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Edit the specified bill
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Identifier.</param>
|
||||||
|
[Authorize(Roles="Blogger")]
|
||||||
|
public ActionResult Edit (long postid)
|
||||||
|
{
|
||||||
|
|
||||||
|
BlogEntry e = BlogManager.GetForEditing (postid);
|
||||||
|
string user = Membership.GetUser ().UserName;
|
||||||
|
Profile pr = new Profile (ProfileBase.Create(e.Author));
|
||||||
|
ViewData ["BlogTitle"] = pr.BlogTitle;
|
||||||
|
ViewData ["LOGIN"] = user;
|
||||||
|
ViewData ["Id"] = postid;
|
||||||
|
// Populates the circles combo items
|
||||||
|
|
||||||
|
if (e.AllowedCircles == null)
|
||||||
|
e.AllowedCircles = new long[0];
|
||||||
|
|
||||||
|
ViewData ["AllowedCircles"] =
|
||||||
|
CircleManager.DefaultProvider.List (
|
||||||
|
Membership.GetUser ().UserName).Select (x => new SelectListItem {
|
||||||
|
Value = x.Id.ToString(),
|
||||||
|
Text = x.Title,
|
||||||
|
Selected = e.AllowedCircles.Contains (x.Id)
|
||||||
|
});
|
||||||
|
return View (e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Comment the specified model.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model">Model.</param>
|
||||||
|
[Authorize]
|
||||||
|
public ActionResult Comment (Comment model)
|
||||||
|
{
|
||||||
|
string username = Membership.GetUser ().UserName;
|
||||||
|
ViewData ["SiteName"] = sitename;
|
||||||
|
if (ModelState.IsValid) {
|
||||||
|
BlogManager.Comment (username, model.PostId, model.CommentText, model.Visible);
|
||||||
|
return GetPost (model.PostId);
|
||||||
|
}
|
||||||
|
return GetPost (model.PostId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove the specified blog entry, by its author and title,
|
||||||
|
/// using returnUrl as the URL to return to,
|
||||||
|
/// and confirm as a proof you really know what you do.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Title.</param>
|
||||||
|
/// <param name="user">User.</param>
|
||||||
|
/// <param name="returnUrl">Return URL.</param>
|
||||||
|
/// <param name="confirm">If set to <c>true</c> confirm.</param>
|
||||||
|
[Authorize(Roles="Blogger")]
|
||||||
|
public ActionResult RemoveTitle (string user, string title, string returnUrl, bool confirm = false)
|
||||||
|
{
|
||||||
|
if (returnUrl == null)
|
||||||
|
if (Request.UrlReferrer != null)
|
||||||
|
returnUrl = Request.UrlReferrer.AbsoluteUri;
|
||||||
|
ViewData ["returnUrl"] = returnUrl;
|
||||||
|
ViewData ["Author"] = user;
|
||||||
|
ViewData ["Title"] = title;
|
||||||
|
|
||||||
|
if (Membership.GetUser ().UserName != user)
|
||||||
|
if (!Roles.IsUserInRole("Admin"))
|
||||||
|
throw new AuthorizationDenied (user);
|
||||||
|
if (!confirm)
|
||||||
|
return View ("RemoveTitle");
|
||||||
|
BlogManager.RemoveTitle (user, title);
|
||||||
|
if (returnUrl == null)
|
||||||
|
RedirectToAction ("Index", new { user = user });
|
||||||
|
return Redirect (returnUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the post.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The post.</returns>
|
||||||
|
/// <param name="id">Identifier.</param>
|
||||||
|
/// <param name="returnUrl">Return URL.</param>
|
||||||
|
/// <param name="confirm">If set to <c>true</c> confirm.</param>
|
||||||
|
[Authorize(Roles="Blogger")]
|
||||||
|
public ActionResult RemovePost (long postid, string returnUrl, bool confirm = false)
|
||||||
|
{
|
||||||
|
// ensures the access control
|
||||||
|
BlogEntry e = BlogManager.GetForEditing (postid);
|
||||||
|
if (e == null)
|
||||||
|
return new HttpNotFoundResult ("post id "+postid.ToString());
|
||||||
|
ViewData ["id"] = postid;
|
||||||
|
ViewData ["returnUrl"] = string.IsNullOrWhiteSpace(returnUrl)?
|
||||||
|
Request.UrlReferrer.AbsoluteUri.ToString(): returnUrl;
|
||||||
|
// TODO: cleaner way to disallow deletion
|
||||||
|
if (!confirm)
|
||||||
|
return View ("RemovePost",e);
|
||||||
|
BlogManager.RemovePost (postid);
|
||||||
|
if (string.IsNullOrWhiteSpace(returnUrl))
|
||||||
|
return RedirectToAction ("Index");
|
||||||
|
return Redirect (returnUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,67 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using System.IO;
|
||||||
|
using System.Web.Security;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using Yavsc.Model.FileSystem;
|
||||||
|
|
||||||
|
namespace Yavsc.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// File system controller.
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
public class FileSystemController : Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize the specified requestContext.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestContext">Request context.</param>
|
||||||
|
[Authorize]
|
||||||
|
protected override void Initialize (System.Web.Routing.RequestContext requestContext)
|
||||||
|
{
|
||||||
|
base.Initialize (requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Index this instance.
|
||||||
|
/// </summary>
|
||||||
|
[Authorize]
|
||||||
|
public ActionResult Index (string user, string filename)
|
||||||
|
{
|
||||||
|
WebFileSystemManager fsmgr = new WebFileSystemManager ();
|
||||||
|
var files = fsmgr.GetFiles (user,filename);
|
||||||
|
return View (files);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Post the specified id.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Identifier.</param>
|
||||||
|
public ActionResult Post (string id)
|
||||||
|
{
|
||||||
|
return View ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Details the specified user and filename.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">User.</param>
|
||||||
|
/// <param name="filename">Filename.</param>
|
||||||
|
public ActionResult Details (string user, string filename)
|
||||||
|
{
|
||||||
|
WebFileSystemManager fsmgr = new WebFileSystemManager ();
|
||||||
|
FileInfo fi = fsmgr.FileInfo (filename);
|
||||||
|
|
||||||
|
ViewData ["filename"] = filename;
|
||||||
|
// TODO : ensure that we use the default port for
|
||||||
|
// the used sheme
|
||||||
|
ViewData ["url"] = Url.Content("~/users/"+user+"/"+filename);
|
||||||
|
return View (fi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,263 @@
|
|||||||
|
using System;
|
||||||
|
using Yavsc;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using System.Web;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.IO;
|
||||||
|
using Yavsc.Controllers;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Yavsc.Model;
|
||||||
|
using Yavsc.Model.WorkFlow;
|
||||||
|
using System.Web.Security;
|
||||||
|
using System.Threading;
|
||||||
|
using Yavsc.Model.FrontOffice;
|
||||||
|
using Yavsc.Model.FileSystem;
|
||||||
|
using Yavsc.Model.Calendar;
|
||||||
|
using System.Configuration;
|
||||||
|
using Yavsc.Helpers;
|
||||||
|
using Yavsc.Model.FrontOffice.Catalog;
|
||||||
|
|
||||||
|
namespace Yavsc.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Front office controller.
|
||||||
|
/// Access granted to all
|
||||||
|
/// </summary>
|
||||||
|
public class FrontOfficeController : Controller
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The wfmgr.
|
||||||
|
/// </summary>
|
||||||
|
protected WorkFlowManager wfmgr = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize the specified requestContext.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestContext">Request context.</param>
|
||||||
|
protected override void Initialize (System.Web.Routing.RequestContext requestContext)
|
||||||
|
{
|
||||||
|
base.Initialize (requestContext);
|
||||||
|
wfmgr = new WorkFlowManager ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Index this instance.
|
||||||
|
/// </summary>
|
||||||
|
public ActionResult Index ()
|
||||||
|
{
|
||||||
|
return View ();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Pub the Event
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The pub.</returns>
|
||||||
|
/// <param name="model">Model.</param>
|
||||||
|
public ActionResult EventPub (EventPub model)
|
||||||
|
{
|
||||||
|
return View (model);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Estimates this instance.
|
||||||
|
/// </summary>
|
||||||
|
[Authorize]
|
||||||
|
public ActionResult Estimates (string client)
|
||||||
|
{
|
||||||
|
var u = Membership.GetUser ();
|
||||||
|
if (u == null) // There was no redirection to any login page
|
||||||
|
throw new ConfigurationErrorsException ("no redirection to any login page");
|
||||||
|
|
||||||
|
string username = u.UserName;
|
||||||
|
Estimate [] estims = wfmgr.GetUserEstimates (username);
|
||||||
|
ViewData ["UserName"] = username;
|
||||||
|
ViewData ["ResponsibleCount"] =
|
||||||
|
Array.FindAll (
|
||||||
|
estims,
|
||||||
|
x => x.Responsible == username).Length;
|
||||||
|
ViewData ["ClientCount"] =
|
||||||
|
Array.FindAll (
|
||||||
|
estims,
|
||||||
|
x => x.Client == username).Length;
|
||||||
|
return View (estims);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Estimate the specified id.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Identifier.</param>
|
||||||
|
public ActionResult Get (long id)
|
||||||
|
{
|
||||||
|
Estimate f = wfmgr.GetEstimate (id);
|
||||||
|
if (f == null) {
|
||||||
|
ModelState.AddModelError ("Id", "Wrong Id");
|
||||||
|
return View (new Estimate () { Id=id } );
|
||||||
|
}
|
||||||
|
return View (f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Estimate the specified model and submit.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model">Model.</param>
|
||||||
|
/// <param name="submit">Submit.</param>
|
||||||
|
[Authorize]
|
||||||
|
public ActionResult Estimate (Estimate model, string submit)
|
||||||
|
{
|
||||||
|
string username = Membership.GetUser().UserName;
|
||||||
|
// Obsolete, set in master page
|
||||||
|
ViewData ["WebApiBase"] = Url.Content(Yavsc.WebApiConfig.UrlPrefixRelative);
|
||||||
|
ViewData ["WABASEWF"] = ViewData ["WebApiBase"] + "/WorkFlow";
|
||||||
|
if (submit == null) {
|
||||||
|
if (model.Id > 0) {
|
||||||
|
Estimate f = wfmgr.GetEstimate (model.Id);
|
||||||
|
if (f == null) {
|
||||||
|
ModelState.AddModelError ("Id", "Wrong Id");
|
||||||
|
return View (model);
|
||||||
|
}
|
||||||
|
model = f;
|
||||||
|
ModelState.Clear ();
|
||||||
|
if (username != model.Responsible
|
||||||
|
&& username != model.Client
|
||||||
|
&& !Roles.IsUserInRole ("FrontOffice"))
|
||||||
|
throw new UnauthorizedAccessException ("You're not allowed to view this estimate");
|
||||||
|
} else if (model.Id == 0) {
|
||||||
|
if (string.IsNullOrWhiteSpace(model.Responsible))
|
||||||
|
model.Responsible = username;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (model.Id == 0) // if (submit == "Create")
|
||||||
|
if (string.IsNullOrWhiteSpace (model.Responsible))
|
||||||
|
model.Responsible = username;
|
||||||
|
if (username != model.Responsible
|
||||||
|
&& !Roles.IsUserInRole ("FrontOffice"))
|
||||||
|
throw new UnauthorizedAccessException ("You're not allowed to modify this estimate");
|
||||||
|
|
||||||
|
if (ModelState.IsValid) {
|
||||||
|
if (model.Id == 0)
|
||||||
|
model = wfmgr.CreateEstimate (
|
||||||
|
username,
|
||||||
|
model.Client, model.Title, model.Description);
|
||||||
|
else {
|
||||||
|
wfmgr.UpdateEstimate (model);
|
||||||
|
model = wfmgr.GetEstimate (model.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return View (model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Catalog this instance.
|
||||||
|
/// </summary>
|
||||||
|
[AcceptVerbs ("GET")]
|
||||||
|
public ActionResult Catalog ()
|
||||||
|
{
|
||||||
|
return View (
|
||||||
|
CatalogManager.GetCatalog ()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Catalog this instance.
|
||||||
|
/// </summary>
|
||||||
|
[AcceptVerbs ("GET")]
|
||||||
|
public ActionResult Brand (string id)
|
||||||
|
{
|
||||||
|
Catalog c = CatalogManager.GetCatalog ();
|
||||||
|
ViewData ["BrandName"] = id;
|
||||||
|
return View (c.GetBrand (id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// get the product category
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The category object.</returns>
|
||||||
|
/// <param name="brandid">Brand id.</param>
|
||||||
|
/// <param name="pcid">Product category Id.</param>
|
||||||
|
[AcceptVerbs ("GET")]
|
||||||
|
public ActionResult ProductCategory (string brandid, string pcid)
|
||||||
|
{
|
||||||
|
ViewData ["BrandId"] = brandid;
|
||||||
|
ViewData ["ProductCategoryId"] = pcid;
|
||||||
|
|
||||||
|
var cat = CatalogManager.GetCatalog ();
|
||||||
|
if (cat == null)
|
||||||
|
throw new Exception ("No catalog");
|
||||||
|
var brand = cat.GetBrand (brandid);
|
||||||
|
if (brand == null)
|
||||||
|
throw new Exception ("Not a brand id: "+brandid);
|
||||||
|
var pcat = brand.GetProductCategory (pcid);
|
||||||
|
if (pcat == null)
|
||||||
|
throw new Exception ("Not a product category id in this brand: " + pcid);
|
||||||
|
return View (pcat);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Product the specified id, pc and pref.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Identifier.</param>
|
||||||
|
/// <param name="pc">Pc.</param>
|
||||||
|
/// <param name="pref">Preference.</param>
|
||||||
|
[AcceptVerbs ("GET")]
|
||||||
|
public ActionResult Product (string id, string pc, string pref)
|
||||||
|
{
|
||||||
|
Product p = null;
|
||||||
|
ViewData ["BrandName"] = id;
|
||||||
|
ViewData ["ProdCatRef"] = pc;
|
||||||
|
ViewData ["ProdRef"] = pref;
|
||||||
|
Catalog cat = CatalogManager.GetCatalog ();
|
||||||
|
if (cat == null) {
|
||||||
|
YavscHelpers.Notify(ViewData, "Catalog introuvable");
|
||||||
|
ViewData ["RefType"] = "Catalog";
|
||||||
|
return View ("ReferenceNotFound");
|
||||||
|
}
|
||||||
|
Brand b = cat.GetBrand (id);
|
||||||
|
if (b == null) {
|
||||||
|
ViewData ["RefType"] = "Brand";
|
||||||
|
return View ("ReferenceNotFound");
|
||||||
|
}
|
||||||
|
ProductCategory pcat = b.GetProductCategory (pc);
|
||||||
|
if (pcat == null) {
|
||||||
|
ViewData ["RefType"] = "ProductCategory";
|
||||||
|
return View ("ReferenceNotFound");
|
||||||
|
}
|
||||||
|
ViewData ["ProdCatName"] = pcat.Name;
|
||||||
|
p = pcat.GetProduct (pref);
|
||||||
|
if (p.CommandForm == null)
|
||||||
|
p.CommandForm = b.DefaultForm;
|
||||||
|
|
||||||
|
return View ((p is Service) ? "Service" : "Product", p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Basket this instance.
|
||||||
|
/// </summary>
|
||||||
|
[Authorize]
|
||||||
|
public ActionResult Basket ()
|
||||||
|
{
|
||||||
|
return View (wfmgr.GetCommands (Membership.GetUser ().UserName));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Command the specified collection.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="collection">Collection.</param>
|
||||||
|
[HttpPost]
|
||||||
|
[Authorize]
|
||||||
|
public ActionResult Command (FormCollection collection)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Add specified product command to the basket,
|
||||||
|
// saves it in db
|
||||||
|
new Command(collection,HttpContext.Request.Files);
|
||||||
|
YavscHelpers.Notify(ViewData, LocalizedText.Item_added_to_basket);
|
||||||
|
return View (collection);
|
||||||
|
} catch (Exception e) {
|
||||||
|
YavscHelpers.Notify(ViewData,"Exception:" + e.Message);
|
||||||
|
return View (collection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,138 @@
|
|||||||
|
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
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <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 ()
|
||||||
|
{
|
||||||
|
if (Session.IsNewSession) {
|
||||||
|
string uid = (!Request.IsAuthenticated) ? Request.AnonymousID : User.Identity.Name;
|
||||||
|
ProfileBase pr =
|
||||||
|
ProfileBase.Create (uid);
|
||||||
|
bool ac = (bool) pr.GetPropertyValue ("allowcookies");
|
||||||
|
if (!ac)
|
||||||
|
YavscHelpers.Notify (ViewData, LocalizedText.ThisSiteUsesCookies,
|
||||||
|
"function(){Yavsc.ajax(\"/Yavsc/AllowCookies\", { id:'"+uid+"' });}",
|
||||||
|
LocalizedText.I_understood);
|
||||||
|
}
|
||||||
|
|
||||||
|
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="" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,95 @@
|
|||||||
|
//
|
||||||
|
// ErrorHtmlFormatter.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// paul <${AuthorEmail}>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2015 paul
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Net.Http.Formatting;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using System.Net;
|
||||||
|
using MarkdownDeep;
|
||||||
|
using Yavsc.Helpers;
|
||||||
|
using Yavsc.Model.Blogs;
|
||||||
|
|
||||||
|
namespace Yavsc.Formatters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Formats a given error message to respond
|
||||||
|
/// in case of error, and in an html format
|
||||||
|
/// </summary>
|
||||||
|
public class ErrorHtmlFormatter:SimpleFormatter {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the title.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The title.</value>
|
||||||
|
public string Title { get ; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the error code.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The error code.</value>
|
||||||
|
public HttpStatusCode ErrorCode { get ; set; }
|
||||||
|
|
||||||
|
string doctype="<!DOCTYPE html>";
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Yavsc.Formatters.ErrorHtmlFormatter"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="errorCode">Error code.</param>
|
||||||
|
/// <param name="title">Title.</param>
|
||||||
|
public ErrorHtmlFormatter
|
||||||
|
(HttpStatusCode errorCode, string title):base("text/html")
|
||||||
|
{
|
||||||
|
ErrorCode = errorCode;
|
||||||
|
Title = title;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WriteToStream (Type type, object value, Stream stream, HttpContent content)
|
||||||
|
{
|
||||||
|
// TODO create a type containing T4 parameters, and generate from them
|
||||||
|
using (var writer = new StreamWriter(stream))
|
||||||
|
{
|
||||||
|
string message = value as string;
|
||||||
|
TagBuilder doc = new TagBuilder ("html");
|
||||||
|
TagBuilder body = new TagBuilder ("body");
|
||||||
|
TagBuilder h1 = new TagBuilder ("h1");
|
||||||
|
TagBuilder p = new TagBuilder ("p");
|
||||||
|
TagBuilder head = new TagBuilder ("head");
|
||||||
|
head.InnerHtml = "<meta http-equiv=\"Content-Type\" " +
|
||||||
|
"content=\"text/html; charset=utf-8\"/>" +
|
||||||
|
"<link rel=\"stylesheet\" " +
|
||||||
|
"href=\"/Theme/style.css\" />" +
|
||||||
|
"<link rel=\"icon\" type=\"image/png\"" +
|
||||||
|
" href=\"/favicon.png\" />";
|
||||||
|
p.InnerHtml = MarkdownHelper.Markdown(message).ToHtmlString();
|
||||||
|
h1.InnerHtml = MvcHtmlString.Create (Title).ToHtmlString();
|
||||||
|
body.InnerHtml = h1.ToString()+p.ToString ();
|
||||||
|
doc.InnerHtml = head.ToString()+"\n"+body.ToString ();
|
||||||
|
writer.WriteLine (doctype);
|
||||||
|
writer.Write (doc.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
//
|
||||||
|
// TexToPdfFormatter.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// Paul Schneider <paulschneider@free.fr>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2015 Paul Schneider
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
using System;
|
||||||
|
using System.Net.Http.Formatting;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Web;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Net.Http;
|
||||||
|
using Yavsc.Helpers;
|
||||||
|
|
||||||
|
namespace Yavsc.Formatters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Formatter exception.
|
||||||
|
/// </summary>
|
||||||
|
public class FormatterException : Exception
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Yavsc.Formatters.FormatterException"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">Message.</param>
|
||||||
|
public FormatterException(string message):base(message)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Yavsc.Formatters.FormatterException"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">Message.</param>
|
||||||
|
/// <param name="innerException">Inner exception.</param>
|
||||||
|
public FormatterException(string message,Exception innerException):base(message,innerException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Output { get; set; }
|
||||||
|
public string Error { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,100 @@
|
|||||||
|
//
|
||||||
|
// RssFormatter.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// paul <${AuthorEmail}>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2015 paul
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Net.Http.Formatting;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using System.Net;
|
||||||
|
using Yavsc.Model;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Yavsc.Formatters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Rss feeds formatter.
|
||||||
|
/// </summary>
|
||||||
|
public class RssFeedsFormatter:SimpleFormatter
|
||||||
|
{
|
||||||
|
string doctype = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Yavsc.Formatters.RssFeedsFormatter"/> class.
|
||||||
|
/// </summary>
|
||||||
|
public RssFeedsFormatter
|
||||||
|
() : base ("application/rss+xml")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private const string dateformat = "ddd, dd MMM yyyy HH:mm:ss K";
|
||||||
|
public override void WriteToStream (Type type, object value, Stream stream, HttpContent content)
|
||||||
|
{
|
||||||
|
RssFeedsChannel feeds = value as RssFeedsChannel;
|
||||||
|
using (var writer = new StreamWriter (stream)) {
|
||||||
|
TagBuilder rss = new TagBuilder ("rss");
|
||||||
|
rss.Attributes.Add ("version", "2.0");
|
||||||
|
TagBuilder channel = new TagBuilder ("channel");
|
||||||
|
TagBuilder title = new TagBuilder ("title");
|
||||||
|
TagBuilder description = new TagBuilder ("description");
|
||||||
|
TagBuilder lastBuildDate = new TagBuilder ("lastBuildDate");
|
||||||
|
TagBuilder link = new TagBuilder ("link");
|
||||||
|
|
||||||
|
title.InnerHtml = MvcHtmlString.Create (feeds.Title).ToHtmlString ();
|
||||||
|
description.InnerHtml = MvcHtmlString.Create (feeds.Description).ToHtmlString ();
|
||||||
|
lastBuildDate.InnerHtml = MvcHtmlString.Create (feeds.LastBuildDate.ToString (dateformat)).ToHtmlString ();
|
||||||
|
link.InnerHtml = MvcHtmlString.Create (feeds.Link).ToHtmlString ();
|
||||||
|
StringBuilder sb = new StringBuilder ();
|
||||||
|
foreach (RssFeedsEntry e in feeds.Entries) {
|
||||||
|
TagBuilder item = new TagBuilder ("item");
|
||||||
|
TagBuilder ititle = new TagBuilder ("title");
|
||||||
|
ititle.InnerHtml = e.Title;
|
||||||
|
|
||||||
|
TagBuilder idescription = new TagBuilder ("description");
|
||||||
|
idescription.InnerHtml = MvcHtmlString.Create (e.Description).ToHtmlString ();
|
||||||
|
TagBuilder ipubDate = new TagBuilder ("pubDate");
|
||||||
|
ipubDate.InnerHtml = MvcHtmlString.Create (
|
||||||
|
e.PubDate.ToString (dateformat)).ToHtmlString ();
|
||||||
|
|
||||||
|
TagBuilder ilink = new TagBuilder ("link");
|
||||||
|
ilink.InnerHtml = MvcHtmlString.Create (e.Link).ToHtmlString ();
|
||||||
|
|
||||||
|
item.InnerHtml = ititle.ToString () + "\n" +
|
||||||
|
idescription.ToString () + "\n" +
|
||||||
|
ipubDate.ToString () + "\n" +
|
||||||
|
ilink.ToString () + "\n";
|
||||||
|
|
||||||
|
sb.Append (item.ToString () + "\n");
|
||||||
|
}
|
||||||
|
channel.InnerHtml = title.ToString () + "\n" +
|
||||||
|
description.ToString () + "\n" +
|
||||||
|
lastBuildDate.ToString () + "\n" +
|
||||||
|
link.ToString () + "\n" +
|
||||||
|
sb.ToString () + "\n";
|
||||||
|
rss.InnerHtml = channel.ToString ();
|
||||||
|
writer.WriteLine (doctype);
|
||||||
|
writer.Write (rss.ToString ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
<%@ Application Inherits="Yavsc.MvcApplication" %>
|
@ -0,0 +1,132 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Routing;
|
||||||
|
using Yavsc.Formatters;
|
||||||
|
using Yavsc.Model.FrontOffice;
|
||||||
|
using System.Web.SessionState;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using System.Web.Http;
|
||||||
|
using System.Web.WebPages.Scope;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Web.Configuration;
|
||||||
|
|
||||||
|
namespace Yavsc
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Mvc application.
|
||||||
|
/// </summary>
|
||||||
|
public class MvcApplication : System.Web.HttpApplication
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Registers the routes.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="routes">Routes.</param>
|
||||||
|
public static void RegisterRoutes (RouteCollection routes)
|
||||||
|
{
|
||||||
|
// Should be FrontOffice in a POS,
|
||||||
|
string defaultController =
|
||||||
|
WebConfigurationManager.AppSettings ["DefaultController"];
|
||||||
|
if (defaultController == null)
|
||||||
|
defaultController = "Home";
|
||||||
|
routes.IgnoreRoute ("{resource}.axd/{*pathInfo}"); // not used
|
||||||
|
routes.IgnoreRoute ("Scripts/{*pathInfo}"); // web user side scripts
|
||||||
|
routes.IgnoreRoute ("App_Theme/{*pathInfo}"); // sites themes
|
||||||
|
routes.IgnoreRoute ("users/{*pathInfo}"); // user's files
|
||||||
|
routes.IgnoreRoute ("avatars/{*pathInfo}"); // user's avatar
|
||||||
|
routes.IgnoreRoute ("bfiles/{*pathInfo}"); // Blog files
|
||||||
|
routes.IgnoreRoute ("xmldoc/{*pathInfo}"); // xml doc
|
||||||
|
routes.IgnoreRoute ("htmldoc/{*pathInfo}"); // html doc
|
||||||
|
routes.IgnoreRoute ("fonts/{*pathInfo}"); // fonts
|
||||||
|
routes.IgnoreRoute ("favicon.ico"); // favorite icon
|
||||||
|
routes.IgnoreRoute ("favicon.png"); // favorite icon
|
||||||
|
routes.IgnoreRoute ("robots.txt"); // for search engine robots
|
||||||
|
routes.MapRoute (
|
||||||
|
"Titles",
|
||||||
|
"title/{title}",
|
||||||
|
new { controller = "Blogs", action = "Index",
|
||||||
|
title=UrlParameter.Optional }
|
||||||
|
);
|
||||||
|
routes.MapRoute (
|
||||||
|
"Blogs",
|
||||||
|
"blog/{user}",
|
||||||
|
new { controller = "Blogs",
|
||||||
|
action = "UserPosts",
|
||||||
|
user="Paul Schneider" }
|
||||||
|
);
|
||||||
|
|
||||||
|
routes.MapRoute (
|
||||||
|
"BlogByTitle",
|
||||||
|
"by/{user}/{title}/{id}",
|
||||||
|
new { controller = "Blogs",
|
||||||
|
action = "UserPosts",
|
||||||
|
user="Paul Schneider",
|
||||||
|
title=UrlParameter.Optional,
|
||||||
|
id=UrlParameter.Optional }
|
||||||
|
);
|
||||||
|
routes.MapRoute (
|
||||||
|
"BlogById",
|
||||||
|
"b/{action}/{postid}",
|
||||||
|
new { controller = "Blogs", action = "Index",
|
||||||
|
postid=UrlParameter.Optional }
|
||||||
|
);
|
||||||
|
routes.MapRoute (
|
||||||
|
"BackCompat",
|
||||||
|
"Blogs/{action}/{user}/{title}",
|
||||||
|
new { controller = "Blogs", action = "Index", user = UrlParameter.Optional, title = UrlParameter.Optional }
|
||||||
|
);
|
||||||
|
|
||||||
|
routes.MapRoute (
|
||||||
|
"Default",
|
||||||
|
"{controller}/{action}/{id}",
|
||||||
|
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Starts the Application.
|
||||||
|
/// </summary>
|
||||||
|
protected void Application_Start ()
|
||||||
|
{
|
||||||
|
AreaRegistration.RegisterAllAreas ();
|
||||||
|
WebApiConfig.Register (GlobalConfiguration.Configuration);
|
||||||
|
RegisterRoutes (RouteTable.Routes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applications the post authorize request.
|
||||||
|
/// </summary>
|
||||||
|
protected void Application_PostAuthorizeRequest()
|
||||||
|
{
|
||||||
|
if (IsWebApiRequest())
|
||||||
|
{
|
||||||
|
HttpContext.Current.SetSessionStateBehavior(SessionStateBehavior.Required);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsWebApiRequest()
|
||||||
|
{
|
||||||
|
return HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath.StartsWith(WebApiConfig.UrlPrefixRelative);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// begins a request against this application.
|
||||||
|
/// </summary>
|
||||||
|
protected void Application_BeginRequest()
|
||||||
|
{
|
||||||
|
var ob = typeof(
|
||||||
|
AspNetRequestScopeStorageProvider).Assembly.GetType(
|
||||||
|
"System.Web.WebPages.WebPageHttpModule").GetProperty
|
||||||
|
("AppStartExecuteCompleted",
|
||||||
|
BindingFlags.NonPublic | BindingFlags.Static);
|
||||||
|
ob.SetValue(null, true, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,78 @@
|
|||||||
|
//
|
||||||
|
// Manager.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// Paul Schneider <paulschneider@free.fr>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2015 Paul Schneider
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using Yavsc.Helpers;
|
||||||
|
using System.Web.Profile;
|
||||||
|
using Yavsc.Model.Google;
|
||||||
|
using System.Net;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Yavsc.Helpers.Google
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Google base API client.
|
||||||
|
/// This class implements the identification values for a Google Api,
|
||||||
|
/// and provides some scope values.
|
||||||
|
/// </summary>
|
||||||
|
public class ApiClient
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The CLIENT Id.
|
||||||
|
/// </summary>
|
||||||
|
public static string CLIENT_ID { get ; set ; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The CLIENt SECREt
|
||||||
|
/// </summary>
|
||||||
|
public static string CLIENT_SECRET { get ; set ; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The API KEY.
|
||||||
|
/// </summary>
|
||||||
|
public static string API_KEY { get ; set ; }
|
||||||
|
/* // to use in descendence
|
||||||
|
*
|
||||||
|
protected static string getPeopleUri = "https://www.googleapis.com/plus/v1/people";
|
||||||
|
private static string authUri = "https://accounts.google.com/o/oauth2/auth";
|
||||||
|
*/
|
||||||
|
/// <summary>
|
||||||
|
/// The Map tracks scope .
|
||||||
|
/// </summary>
|
||||||
|
protected static string scopeTracks = "https://www.googleapis.com/auth/tracks";
|
||||||
|
/// <summary>
|
||||||
|
/// The calendar scope.
|
||||||
|
/// </summary>
|
||||||
|
protected static string scopeCalendar = "https://www.googleapis.com/auth/calendar";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The scope openid.
|
||||||
|
/// </summary>
|
||||||
|
protected static string[] scopeOpenid = {
|
||||||
|
"openid",
|
||||||
|
"profile",
|
||||||
|
"email"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,138 @@
|
|||||||
|
//
|
||||||
|
// Calendar.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// Paul Schneider <paulschneider@free.fr>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2015 Paul Schneider
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using Yavsc.Helpers;
|
||||||
|
using System.Web.Profile;
|
||||||
|
using Yavsc.Model.Google;
|
||||||
|
using System.Net;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Web;
|
||||||
|
using Yavsc.Model;
|
||||||
|
|
||||||
|
namespace Yavsc.Helpers.Google
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Google Calendar API client.
|
||||||
|
/// </summary>
|
||||||
|
public class CalendarApi : ApiClient
|
||||||
|
{
|
||||||
|
public CalendarApi(string apiKey)
|
||||||
|
{
|
||||||
|
API_KEY = apiKey;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The get cal list URI.
|
||||||
|
/// </summary>
|
||||||
|
protected static string getCalListUri = "https://www.googleapis.com/calendar/v3/users/me/calendarList";
|
||||||
|
/// <summary>
|
||||||
|
/// The get cal entries URI.
|
||||||
|
/// </summary>
|
||||||
|
protected static string getCalEntriesUri = "https://www.googleapis.com/calendar/v3/calendars/{0}/events";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The date format.
|
||||||
|
/// </summary>
|
||||||
|
private static string dateFormat = "yyyy-MM-ddTHH:mm:ss";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The time zone. TODO Fixme with machine time zone
|
||||||
|
/// </summary>
|
||||||
|
private string timeZone = "+01:00";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the calendar list.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The calendars.</returns>
|
||||||
|
/// <param name="cred">Cred.</param>
|
||||||
|
public CalendarList GetCalendars (string cred)
|
||||||
|
{
|
||||||
|
CalendarList res = null;
|
||||||
|
HttpWebRequest webreq = WebRequest.CreateHttp (getCalListUri);
|
||||||
|
webreq.Headers.Add (HttpRequestHeader.Authorization, cred);
|
||||||
|
webreq.Method = "GET";
|
||||||
|
webreq.ContentType = "application/http";
|
||||||
|
using (WebResponse resp = webreq.GetResponse ()) {
|
||||||
|
using (Stream respstream = resp.GetResponseStream ()) {
|
||||||
|
var cr = new Newtonsoft.Json.JsonSerializer ();
|
||||||
|
using (var rdr = new StreamReader (respstream))
|
||||||
|
res = (CalendarList) cr.Deserialize (rdr, typeof(CalendarList));
|
||||||
|
}
|
||||||
|
resp.Close ();
|
||||||
|
}
|
||||||
|
webreq.Abort ();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a calendar.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The calendar.</returns>
|
||||||
|
/// <param name="calid">Calid.</param>
|
||||||
|
/// <param name="mindate">Mindate.</param>
|
||||||
|
/// <param name="maxdate">Maxdate.</param>
|
||||||
|
/// <param name="upr">Upr.</param>
|
||||||
|
public CalendarEventList GetCalendar (string calid, DateTime mindate, DateTime maxdate,string cred)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace (calid))
|
||||||
|
throw new Exception ("the calendar identifier is not specified");
|
||||||
|
|
||||||
|
string uri = string.Format (
|
||||||
|
getCalEntriesUri, HttpUtility.UrlEncode (calid)) +
|
||||||
|
string.Format ("?orderBy=startTime&singleEvents=true&timeMin={0}&timeMax={1}&key=" + API_KEY,
|
||||||
|
HttpUtility.UrlEncode (mindate.ToString (dateFormat) + timeZone),
|
||||||
|
HttpUtility.UrlEncode (maxdate.ToString (dateFormat) + timeZone));
|
||||||
|
|
||||||
|
HttpWebRequest webreq = WebRequest.CreateHttp (uri);
|
||||||
|
var cr = new Newtonsoft.Json.JsonSerializer ();
|
||||||
|
webreq.Headers.Add (HttpRequestHeader.Authorization, cred);
|
||||||
|
webreq.Method = "GET";
|
||||||
|
webreq.ContentType = "application/http";
|
||||||
|
CalendarEventList res = null;
|
||||||
|
try {
|
||||||
|
using (WebResponse resp = webreq.GetResponse ()) {
|
||||||
|
using (Stream respstream = resp.GetResponseStream ()) {
|
||||||
|
try {
|
||||||
|
using (var rdr = new StreamReader(respstream)) {
|
||||||
|
res = (CalendarEventList)
|
||||||
|
cr.Deserialize(rdr,typeof(CalendarEventList));
|
||||||
|
}
|
||||||
|
} catch (Exception ) {
|
||||||
|
respstream.Close ();
|
||||||
|
resp.Close ();
|
||||||
|
webreq.Abort ();
|
||||||
|
throw ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resp.Close ();
|
||||||
|
}
|
||||||
|
} catch (WebException ) {
|
||||||
|
webreq.Abort ();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
webreq.Abort ();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
//
|
||||||
|
// Entity.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// Paul Schneider <paulschneider@free.fr>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2015 Paul Schneider
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using Yavsc.Helpers;
|
||||||
|
using System.Web.Profile;
|
||||||
|
using Yavsc.Model.Google;
|
||||||
|
using System.Net;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Yavsc.Helpers.Google
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Entity.
|
||||||
|
/// </summary>
|
||||||
|
public class Entity
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The I.
|
||||||
|
/// </summary>
|
||||||
|
public string ID;
|
||||||
|
/// <summary>
|
||||||
|
/// The name.
|
||||||
|
/// </summary>
|
||||||
|
public string Name;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The type: AUTOMOBILE: A car or passenger vehicle.
|
||||||
|
/// * TRUCK: A truck or cargo vehicle.
|
||||||
|
/// * WATERCRAFT: A boat or other waterborne vehicle.
|
||||||
|
/// * PERSON: A person.
|
||||||
|
/// </summary>
|
||||||
|
public string Type;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
//
|
||||||
|
// EntityQuery.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// Paul Schneider <paulschneider@free.fr>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2015 Paul Schneider
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using Yavsc.Helpers;
|
||||||
|
using System.Web.Profile;
|
||||||
|
using Yavsc.Model.Google;
|
||||||
|
using System.Net;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Yavsc.Helpers.Google
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Entity query.
|
||||||
|
/// </summary>
|
||||||
|
public class EntityQuery {
|
||||||
|
/// <summary>
|
||||||
|
/// The entity identifiers.
|
||||||
|
/// </summary>
|
||||||
|
public string [] EntityIds;
|
||||||
|
/// <summary>
|
||||||
|
/// The minimum identifier.
|
||||||
|
/// </summary>
|
||||||
|
public string MinId;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
//
|
||||||
|
// PeopleApi.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// Paul Schneider <paul@pschneider.fr>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2015 GNU GPL
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Yavsc.Model.Google;
|
||||||
|
using System.Web.Profile;
|
||||||
|
using System.Web;
|
||||||
|
using Yavsc.Model;
|
||||||
|
using Yavsc.Helpers.Google;
|
||||||
|
|
||||||
|
namespace Yavsc.Helpers.Google
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Google People API.
|
||||||
|
/// </summary>
|
||||||
|
public class PeopleApi: ApiClient
|
||||||
|
{
|
||||||
|
private static string getPeopleUri = "https://www.googleapis.com/plus/v1/people";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the People object associated to the given Google Access Token
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The me.</returns>
|
||||||
|
/// <param name="gat">The Google Access Token object <see cref="AuthToken"/> class.</param>
|
||||||
|
public static People GetMe (AuthToken gat)
|
||||||
|
{
|
||||||
|
People me;
|
||||||
|
var cr = new Newtonsoft.Json.JsonSerializer ();
|
||||||
|
HttpWebRequest webreppro = WebRequest.CreateHttp (getPeopleUri + "/me");
|
||||||
|
webreppro.ContentType = "application/http";
|
||||||
|
webreppro.Headers.Add (HttpRequestHeader.Authorization, gat.token_type + " " + gat.access_token);
|
||||||
|
webreppro.Method = "GET";
|
||||||
|
using (WebResponse proresp = webreppro.GetResponse ()) {
|
||||||
|
using (Stream prresponseStream = proresp.GetResponseStream ()) {
|
||||||
|
using (var rdr = new StreamReader (prresponseStream)) {
|
||||||
|
me = (People)cr.Deserialize (new StreamReader (prresponseStream),typeof(People));
|
||||||
|
}
|
||||||
|
prresponseStream.Close ();
|
||||||
|
}
|
||||||
|
proresp.Close ();
|
||||||
|
}
|
||||||
|
webreppro.Abort ();
|
||||||
|
return me;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Configuration;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using System.Web.Mvc.Ajax;
|
||||||
|
using System.Net.Mail;
|
||||||
|
using Yavsc;
|
||||||
|
using System.Globalization;
|
||||||
|
using Yavsc.Model;
|
||||||
|
|
||||||
|
namespace Yavsc.Helpers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// T.
|
||||||
|
/// </summary>
|
||||||
|
public static class T
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the string.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The string.</returns>
|
||||||
|
/// <param name="msg">Message.</param>
|
||||||
|
public static string GetString(string msg)
|
||||||
|
{
|
||||||
|
string tr = LocalizedText.ResourceManager.GetString (msg.Replace (" ", "_"));
|
||||||
|
return tr==null?msg:tr;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Translate the specified helper and text.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="helper">Helper.</param>
|
||||||
|
/// <param name="text">Text.</param>
|
||||||
|
public static IHtmlString Translate(this HtmlHelper helper, string text)
|
||||||
|
{
|
||||||
|
// Just call the other one, to avoid having two copies (we don't use the HtmlHelper).
|
||||||
|
return new MvcHtmlString(helper.Encode(GetString(text)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Yavsc.Helpers
|
||||||
|
{
|
||||||
|
class TemplateException : Exception
|
||||||
|
{
|
||||||
|
public TemplateException(string message):base(message)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public TemplateException(string message,Exception innerException):base(message,innerException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
|||||||
|
using System;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using Yavsc.Model.Circles;
|
||||||
|
|
||||||
|
namespace Yavsc.Helpers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Link.
|
||||||
|
/// </summary>
|
||||||
|
public class Link {
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the text.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The text.</value>
|
||||||
|
public string Text { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the URL.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The URL.</value>
|
||||||
|
public string Url { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the image.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The image.</value>
|
||||||
|
public string Image { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Thanks helper.
|
||||||
|
/// </summary>
|
||||||
|
public static class ThanksHelper {
|
||||||
|
|
||||||
|
static private ThanksConfigurationSection configurationSection=null;
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the configuration section.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The configuration section.</value>
|
||||||
|
static public ThanksConfigurationSection ConfigurationSection {
|
||||||
|
get {
|
||||||
|
if (configurationSection==null)
|
||||||
|
configurationSection = (ThanksConfigurationSection) ConfigurationManager.GetSection ("system.web/thanks");
|
||||||
|
return configurationSection;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Html code for each entry
|
||||||
|
/// </summary>
|
||||||
|
public static Link[] Thanks (this HtmlHelper helper)
|
||||||
|
{
|
||||||
|
List<Link> result = new List<Link>() ;
|
||||||
|
if (ConfigurationSection == null) return result.ToArray();
|
||||||
|
if (ConfigurationSection.To == null) return result.ToArray();
|
||||||
|
foreach (ThanksConfigurationElement e in ConfigurationSection.To)
|
||||||
|
result.Add( new Link { Url = e.Url, Image=e.Image, Text = e.Name });
|
||||||
|
return result.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,345 @@
|
|||||||
|
using System;
|
||||||
|
using System.Web;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Web.Security;
|
||||||
|
using System.IO;
|
||||||
|
using System.Web.Configuration;
|
||||||
|
using System.Net.Mail;
|
||||||
|
using Yavsc.Model.RolesAndMembers;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using Yavsc.Model.Circles;
|
||||||
|
using System.Web.UI;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Web.Profile;
|
||||||
|
using System.Web.Script.Serialization;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using Yavsc.Model.Messaging;
|
||||||
|
|
||||||
|
namespace Yavsc.Helpers
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Yavsc helpers.
|
||||||
|
/// </summary>
|
||||||
|
public static class YavscHelpers
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
private static string siteName = null;
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the name of the site.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The name of the site.</value>
|
||||||
|
public static string SiteName {
|
||||||
|
get {
|
||||||
|
if (siteName == null)
|
||||||
|
siteName = WebConfigurationManager.AppSettings ["Name"];
|
||||||
|
return siteName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Administrator email
|
||||||
|
private static string admail =
|
||||||
|
WebConfigurationManager.AppSettings ["AdminEmail"];
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the Administrator email.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The admail.</value>
|
||||||
|
public static string Admail {
|
||||||
|
get {
|
||||||
|
return admail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends the activation message.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="helper">Helper.</param>
|
||||||
|
/// <param name="user">User.</param>
|
||||||
|
public static void SendActivationMessage(this System.Web.Http.Routing.UrlHelper helper, MembershipUser user)
|
||||||
|
{
|
||||||
|
SendActivationMessage (helper.Route("Default", new { controller="Account",
|
||||||
|
action = "Validate",
|
||||||
|
key=user.ProviderUserKey.ToString(), id = user.UserName } )
|
||||||
|
, WebConfigurationManager.AppSettings ["RegistrationMessage"],
|
||||||
|
user);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Sends the activation message.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="helper">Helper.</param>
|
||||||
|
/// <param name="user">User.</param>
|
||||||
|
public static void SendActivationMessage(this System.Web.Mvc.UrlHelper helper, MembershipUser user)
|
||||||
|
{
|
||||||
|
SendActivationMessage (
|
||||||
|
string.Format("{2}://{3}/Account/Validate/{1}?key={0}",
|
||||||
|
user.ProviderUserKey.ToString(), user.UserName ,
|
||||||
|
helper.RequestContext.HttpContext.Request.Url.Scheme,
|
||||||
|
helper.RequestContext.HttpContext.Request.Url.Authority
|
||||||
|
)
|
||||||
|
, WebConfigurationManager.AppSettings ["RegistrationMessage"],
|
||||||
|
user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends the activation message.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="validationUrl">Validation URL.</param>
|
||||||
|
/// <param name="registrationMessage">Registration message.</param>
|
||||||
|
/// <param name="user">User.</param>
|
||||||
|
public static void SendActivationMessage(string validationUrl, string registrationMessage, MembershipUser user) {
|
||||||
|
FileInfo fi = new FileInfo (
|
||||||
|
HttpContext.Current.Server.MapPath (registrationMessage));
|
||||||
|
if (!fi.Exists) {
|
||||||
|
throw new Exception(
|
||||||
|
string.Format (
|
||||||
|
"Erreur inattendue (pas de corps de message " +
|
||||||
|
"à envoyer pour le message de confirmation ({0}))",
|
||||||
|
registrationMessage));
|
||||||
|
}
|
||||||
|
|
||||||
|
using (StreamReader sr = fi.OpenText ()) {
|
||||||
|
string body = sr.ReadToEnd ();
|
||||||
|
body = body.Replace ("<%SiteName%>", YavscHelpers.SiteName);
|
||||||
|
body = body.Replace ("<%UserName%>", user.UserName);
|
||||||
|
body = body.Replace ("<%UserActivatonUrl%>", validationUrl);
|
||||||
|
|
||||||
|
using (MailMessage msg = new MailMessage (
|
||||||
|
Admail, user.Email,
|
||||||
|
string.Format ("Validation de votre compte {0}", YavscHelpers.SiteName),
|
||||||
|
body)) {
|
||||||
|
using (SmtpClient sc = new SmtpClient ()) {
|
||||||
|
sc.Send (msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Validates the password reset.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model">Model.</param>
|
||||||
|
/// <param name="errors">Errors.</param>
|
||||||
|
/// <param name="user">User.</param>
|
||||||
|
public static void ValidatePasswordReset(LostPasswordModel model, out StringDictionary errors, out MembershipUser user)
|
||||||
|
{
|
||||||
|
MembershipUserCollection users = null;
|
||||||
|
errors = new StringDictionary ();
|
||||||
|
user = null;
|
||||||
|
if (!string.IsNullOrEmpty (model.UserName)) {
|
||||||
|
users =
|
||||||
|
Membership.FindUsersByName (model.UserName);
|
||||||
|
if (users.Count < 1) {
|
||||||
|
errors.Add ("UserName", "User name not found");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (users.Count != 1) {
|
||||||
|
errors.Add ("UserName", "Found more than one user!(sic)");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty (model.Email)) {
|
||||||
|
users =
|
||||||
|
Membership.FindUsersByEmail (model.Email);
|
||||||
|
if (users.Count < 1) {
|
||||||
|
errors.Add ( "Email", "Email not found");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (users.Count != 1) {
|
||||||
|
errors.Add ("Email", "Found more than one user!(sic)");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (users==null)
|
||||||
|
return;
|
||||||
|
// Assert users.Count == 1
|
||||||
|
foreach (MembershipUser u in users) user = u;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Avatars the URL.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The URL.</returns>
|
||||||
|
/// <param name="helper">Helper.</param>
|
||||||
|
/// <param name="username">Username.</param>
|
||||||
|
public static string AvatarUrl (this System.Web.Mvc.UrlHelper helper, string username) {
|
||||||
|
if (username == null) return null;
|
||||||
|
ProfileBase pr = ProfileBase.Create (username);
|
||||||
|
object avpath = null;
|
||||||
|
if (pr != null) avpath = pr.GetPropertyValue("Avatar");
|
||||||
|
if (avpath == null || avpath is DBNull)
|
||||||
|
return DefaultAvatar==null?"/bfiles/"+username+".png":DefaultAvatar;
|
||||||
|
string avatarLocation = avpath as string;
|
||||||
|
if (avatarLocation.StartsWith ("~/")) {
|
||||||
|
avatarLocation = helper.RouteUrl("Default", avatarLocation);
|
||||||
|
}
|
||||||
|
return avatarLocation;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string avatarDir = "~/avatars";
|
||||||
|
private static string defaultAvatar = null;
|
||||||
|
private static string defaultAvatarMimetype = null;
|
||||||
|
public static string DefaultAvatar {
|
||||||
|
get {
|
||||||
|
if (defaultAvatar == null)
|
||||||
|
GetAvatarConfig ();
|
||||||
|
return defaultAvatar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static string AvatarDir {
|
||||||
|
get {
|
||||||
|
return avatarDir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Yavsc.Controllers.BlogsController"/> class.
|
||||||
|
/// </summary>
|
||||||
|
private static void GetAvatarConfig ()
|
||||||
|
{
|
||||||
|
string[] defaultAvatarSpec = ConfigurationManager.AppSettings.Get ("DefaultAvatar").Split (';');
|
||||||
|
if (defaultAvatarSpec.Length != 2)
|
||||||
|
throw new ConfigurationErrorsException ("the DefaultAvatar spec should be found as <fileName>;<mime-type> ");
|
||||||
|
defaultAvatar = defaultAvatarSpec [0];
|
||||||
|
defaultAvatarMimetype = defaultAvatarSpec [1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Javas the script.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The script.</returns>
|
||||||
|
/// <param name="html">Html.</param>
|
||||||
|
/// <param name="obj">Object.</param>
|
||||||
|
public static string JavaScript(this System.Web.Mvc.HtmlHelper html, object obj)
|
||||||
|
{
|
||||||
|
return JavaScript (obj);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Javas the script.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The script.</returns>
|
||||||
|
/// <param name="obj">Object.</param>
|
||||||
|
public static string JavaScript(object obj)
|
||||||
|
{
|
||||||
|
JavaScriptSerializer serializer = new JavaScriptSerializer();
|
||||||
|
return serializer.Serialize(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Notify(ViewDataDictionary ViewData, string message, string click_action=null, string clickActionName="Ok") {
|
||||||
|
Notify(ViewData, new Notification { body = YavscAjaxHelper.QuoteJavascriptString(message),
|
||||||
|
click_action = click_action, click_action_name = YavscAjaxHelper.QuoteJavascriptString(clickActionName)} ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Notify(ViewDataDictionary ViewData, Notification note) {
|
||||||
|
if (ViewData ["Notifications"] == null)
|
||||||
|
ViewData ["Notifications"] = new List<Notification> ();
|
||||||
|
(ViewData ["Notifications"] as List<Notification>).Add (
|
||||||
|
note ) ;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Files the list.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The list.</returns>
|
||||||
|
/// <param name="html">Html.</param>
|
||||||
|
/// <param name="path">Path.</param>
|
||||||
|
/// <param name="patterns">Patterns.</param>
|
||||||
|
public static IHtmlString FileList(this System.Web.Mvc.HtmlHelper html, string path, string [] patterns = null) {
|
||||||
|
StringWriter str = new StringWriter();
|
||||||
|
HtmlTextWriter writter = new HtmlTextWriter (str);
|
||||||
|
DirectoryInfo di = new DirectoryInfo (HttpContext.Current.Server.MapPath(path));
|
||||||
|
if (!di.Exists)
|
||||||
|
return new System.Web.Mvc.MvcHtmlString ("");
|
||||||
|
var files = new List<FileInfo> ();
|
||||||
|
if (patterns == null)
|
||||||
|
patterns = new string[] { "*" };
|
||||||
|
var url = new System.Web.Mvc.UrlHelper(html.ViewContext.RequestContext,
|
||||||
|
html.RouteCollection);
|
||||||
|
|
||||||
|
foreach (string pattern in patterns)
|
||||||
|
files.AddRange(
|
||||||
|
di.EnumerateFiles (
|
||||||
|
pattern,
|
||||||
|
SearchOption.TopDirectoryOnly));
|
||||||
|
writter.RenderBeginTag ("table");
|
||||||
|
writter.RenderBeginTag ("tr");
|
||||||
|
writter.RenderBeginTag ("td");
|
||||||
|
writter.Write (html.Translate ("Name"));
|
||||||
|
writter.RenderEndTag ();
|
||||||
|
writter.RenderBeginTag ("td");
|
||||||
|
writter.Write (html.Translate ("Created"));
|
||||||
|
writter.RenderEndTag ();
|
||||||
|
writter.RenderBeginTag ("td");
|
||||||
|
writter.Write (html.Translate ("Modified"));
|
||||||
|
writter.RenderEndTag ();
|
||||||
|
writter.RenderEndTag ();
|
||||||
|
foreach (FileInfo fi in files) {
|
||||||
|
writter.RenderBeginTag ("tr");
|
||||||
|
writter.RenderBeginTag ("td");
|
||||||
|
writter.AddAttribute ("href", url.Content(path+"/"+fi.Name));
|
||||||
|
writter.RenderBeginTag ("a");
|
||||||
|
writter.Write (fi.Name);
|
||||||
|
writter.RenderEndTag ();
|
||||||
|
writter.RenderEndTag ();
|
||||||
|
writter.RenderBeginTag ("td");
|
||||||
|
writter.Write (fi.LastWriteTime.ToString ("U"));
|
||||||
|
writter.RenderEndTag ();
|
||||||
|
writter.RenderBeginTag ("td");
|
||||||
|
writter.Write (fi.CreationTime.ToString("U"));
|
||||||
|
writter.RenderEndTag ();
|
||||||
|
writter.RenderEndTag ();
|
||||||
|
}
|
||||||
|
writter.RenderEndTag ();
|
||||||
|
return new System.Web.Mvc.MvcHtmlString (str.ToString ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Renders the page links.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The page links.</returns>
|
||||||
|
/// <param name="helper">Helper.</param>
|
||||||
|
/// <param name="ResultCount">Result count.</param>
|
||||||
|
/// <param name="PageSize">Page size.</param>
|
||||||
|
/// <param name="PageIndex">Page index.</param>
|
||||||
|
public static IHtmlString RenderPageLinks (
|
||||||
|
this HtmlHelper helper,
|
||||||
|
int PageIndex, int PageSize, int ResultCount,
|
||||||
|
string args="?PageIndex={0}",
|
||||||
|
string pagesLabel="Pages: ", string singlePage="",
|
||||||
|
string none="néant"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
StringWriter strwr = new StringWriter ();
|
||||||
|
HtmlTextWriter writer = new HtmlTextWriter(strwr);
|
||||||
|
|
||||||
|
if (ResultCount > 0 && ResultCount > PageSize ) {
|
||||||
|
int pageCount = ((ResultCount-1) / PageSize) + 1;
|
||||||
|
if ( pageCount > 1 ) {
|
||||||
|
writer.WriteEncodedText (pagesLabel);
|
||||||
|
for (int pi = (PageIndex < 5) ? 0 : PageIndex - 5; pi < pageCount && pi < PageIndex + 5; pi++) {
|
||||||
|
if (PageIndex == pi)
|
||||||
|
writer.RenderBeginTag ("b");
|
||||||
|
else {
|
||||||
|
writer.AddAttribute (HtmlTextWriterAttribute.Href,
|
||||||
|
string.Format (args, pi));
|
||||||
|
writer.RenderBeginTag ("a");
|
||||||
|
}
|
||||||
|
writer.Write (pi + 1);
|
||||||
|
writer.RenderEndTag ();
|
||||||
|
writer.Write (" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
writer.Write (singlePage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ResultCount == 0) {
|
||||||
|
writer.WriteEncodedText(none);
|
||||||
|
}
|
||||||
|
return new MvcHtmlString(strwr.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,92 @@
|
|||||||
|
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<% ViewState["orgtitle"] = Html.Translate(Page.Title); %>
|
||||||
|
<% Page.Title = ViewState["orgtitle"] + " - " + YavscHelpers.SiteName; %>
|
||||||
|
<asp:ContentPlaceHolder id="init" runat="server">
|
||||||
|
</asp:ContentPlaceHolder><head runat="server">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<link rel="stylesheet" href="<%=Url.Content("~/App_Themes/style.css")%>" />
|
||||||
|
<link rel="stylesheet" href="<%=Url.Content("~/App_Themes/font-awesome.css")%>" />
|
||||||
|
<link rel="stylesheet" href="<%=Url.Content("~/App_Themes/jquery-ui.css")%>" />
|
||||||
|
<link rel="stylesheet" href="<%=Url.Content("~/App_Themes/prettify.css")%>" />
|
||||||
|
<link rel="stylesheet" href="<%=Url.Content("~/App_Themes/doxy.css")%>" />
|
||||||
|
<link rel="icon" type="image/png" href="/favicon.png?v=3" />
|
||||||
|
<script src="<%=Url.Content("~/Scripts/jquery-2.1.4.min.js")%>"></script>
|
||||||
|
<script src="<%=Url.Content("~/Scripts/jquery-ui-1.11.4.js")%>"></script>
|
||||||
|
<script src="<%=Url.Content("~/Scripts/parallax.js")%>"></script>
|
||||||
|
<script src="<%=Url.Content("~/Scripts/Prettify/run_prettify.js")%>"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var apiBaseUrl = '<%=Url.Content(Yavsc.WebApiConfig.UrlPrefixRelative)%>';
|
||||||
|
</script>
|
||||||
|
<script src="<%=Url.Content("~/Scripts/yavsc.js")%>"></script>
|
||||||
|
<script src="<%=Url.Content("~/Scripts/yavsc.tags.js")%>"></script>
|
||||||
|
<asp:ContentPlaceHolder id="head" runat="server">
|
||||||
|
</asp:ContentPlaceHolder>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header data-type="background" data-speed="8" >
|
||||||
|
<asp:ContentPlaceHolder ID="overHeaderOne" runat="server">
|
||||||
|
<h1><a href="<%= Url.RouteUrl("Default") %>">
|
||||||
|
<%=ViewState["orgtitle"]%></a>
|
||||||
|
- <a href="<%= Url.RouteUrl("Default", new {controller = "Home" , action = "Index" }) %>"><%= YavscHelpers.SiteName %></a>
|
||||||
|
</h1>
|
||||||
|
</asp:ContentPlaceHolder>
|
||||||
|
<asp:ContentPlaceHolder ID="header" runat="server"></asp:ContentPlaceHolder>
|
||||||
|
<div id="notifications"></div>
|
||||||
|
<% if (ViewData ["Notifications"]!=null) { %>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
<% foreach (Notification note in (IEnumerable<Notification>) ViewData ["Notifications"] ) {
|
||||||
|
if (note.click_action == null) {%> Yavsc.notice(<%=note.body%>); <% }
|
||||||
|
else {%> Yavsc.notice(<%=note.body%>, <%=note.click_action%>, <%=note.click_action_name%>); <% } %>
|
||||||
|
<% } %>
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<% } %>
|
||||||
|
</header>
|
||||||
|
<nav data-type="background" data-speed="5">
|
||||||
|
<% if (Membership.GetUser()==null) { %>
|
||||||
|
<a href="<%= Url.RouteUrl("Default", new { controller = "Account", action = "Login", returnUrl=Request.Url.PathAndQuery}) %>" class="menuitem" accesskey = "C">
|
||||||
|
<i class="fa fa-sign-in">Connexion</i>
|
||||||
|
</a>
|
||||||
|
<% } else { %>
|
||||||
|
<a href="<%=Url.RouteUrl("Blogs", new { user = HttpContext.Current.User.Identity.Name } )%>" accesskey = "B" class="menuitem" >
|
||||||
|
<img src="<%=Url.AvatarUrl(HttpContext.Current.User.Identity.Name)%>" alt="vos billets" class="iconsmall" />
|
||||||
|
<span class="hint">Vos billets</span>
|
||||||
|
</a>
|
||||||
|
<a href="<%= Url.RouteUrl("Default", new { controller = "Account", action = "Profile", id = HttpContext.Current.User.Identity.Name} ) %>" accesskey="P" class="menuitem fa fa-user">
|
||||||
|
<%= HttpContext.Current.User.Identity.Name %>
|
||||||
|
<span class="hint"> Édition de votre profile </span>
|
||||||
|
</a>
|
||||||
|
<a href="/Blogs/Post" accesskey="P" class="menuitem fa fa-pencil">
|
||||||
|
<u>P</u>oster
|
||||||
|
<span class="hint">Édition d'un nouveau billet </span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href="<%= Url.RouteUrl("Default", new { controller = "Account", action = "Logout", returnUrl=Request.Url.PathAndQuery}) %>" accesskey = "C" class="menuitem fa fa-sign-out">
|
||||||
|
<%=Html.Translate("Logout")%></a>
|
||||||
|
<% } %>
|
||||||
|
</nav>
|
||||||
|
<main data-type="background" data-speed="10" data-emheight="10" data-posx="0" data-posy="22" >
|
||||||
|
<asp:ContentPlaceHolder ID="MainContent" runat="server">
|
||||||
|
</asp:ContentPlaceHolder>
|
||||||
|
</main>
|
||||||
|
<asp:ContentPlaceHolder ID="MASContent" runat="server">
|
||||||
|
</asp:ContentPlaceHolder>
|
||||||
|
<footer data-type="background" data-speed="5" >
|
||||||
|
<div id="copyr">
|
||||||
|
<a href="http://yavsc.pschneider.fr/Blogs/UserPost/paul/License">© 2015 GNU GENERAL PUBLIC LICENSE <i>Version 3, 29 June 2007</i></a>
|
||||||
|
</div>
|
||||||
|
<%= Html.ActionLink("Formulaire de contact","Contact","Home",null, new { @class="thanks" }) %>
|
||||||
|
<% foreach ( Link link in Html.Thanks()) { %>
|
||||||
|
<a class="thanks" href="<%=link.Url%>"><% if (link.Image !=null) {
|
||||||
|
%><img src="<%= link.Image %>" alt="<%= link.Text %>"/></a>
|
||||||
|
<% } else { %>
|
||||||
|
<a class="thanks" href="<%=link.Url%>"><%= link.Text %></a>
|
||||||
|
<% }} %>
|
||||||
|
</footer><div class="modal"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,107 @@
|
|||||||
|
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<% ViewState["orgtitle"] = Html.Translate(Page.Title); %>
|
||||||
|
<% Page.Title = ViewState["orgtitle"] + " - " + YavscHelpers.SiteName; %>
|
||||||
|
<asp:ContentPlaceHolder id="init" runat="server">
|
||||||
|
</asp:ContentPlaceHolder><head runat="server">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<link rel="stylesheet" href="<%=Url.Content("~/App_Themes/style.css")%>" />
|
||||||
|
<link rel="stylesheet" href="<%=Url.Content("~/App_Themes/font-awesome.css")%>" />
|
||||||
|
<link rel="stylesheet" href="<%=Url.Content("~/App_Themes/jquery-ui.css")%>" />
|
||||||
|
<link rel="stylesheet" href="<%=Url.Content("~/App_Themes/prettify.css")%>" />
|
||||||
|
<link rel="stylesheet" href="<%=Url.Content("~/App_Themes/doxy.css")%>" />
|
||||||
|
<link rel="icon" type="image/png" href="/favicon.png?v=3" />
|
||||||
|
<script src="<%=Url.Content("~/Scripts/jquery-2.1.4.min.js")%>"></script>
|
||||||
|
<script src="<%=Url.Content("~/Scripts/jquery-ui-1.11.4.min.js")%>"></script>
|
||||||
|
<script src="<%=Url.Content("~/Scripts/parallax.js")%>"></script>
|
||||||
|
<script src="<%=Url.Content("~/Scripts/Prettify/run_prettify.js")%>"></script>
|
||||||
|
<script src="<%=Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")%>"></script>
|
||||||
|
<script src="<%=Url.Content("~/Scripts/jquery.validate.min.js")%>"></script>
|
||||||
|
<script src="<%=Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")%>"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var apiBaseUrl = '<%=Url.Content(Yavsc.WebApiConfig.UrlPrefixRelative)%>';
|
||||||
|
</script>
|
||||||
|
<%=Ajax.GlobalizationScript()%>
|
||||||
|
<script src="<%=Url.Content("~/Scripts/yavsc.js")%>"></script>
|
||||||
|
<script src="<%=Url.Content("~/Scripts/yavsc.tags.js")%>"></script>
|
||||||
|
<asp:ContentPlaceHolder id="head" runat="server">
|
||||||
|
</asp:ContentPlaceHolder>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header data-type="background" data-speed="8" >
|
||||||
|
<asp:ContentPlaceHolder ID="overHeaderOne" runat="server">
|
||||||
|
<h1><a href="<%= Url.RouteUrl("Default") %>">
|
||||||
|
<%=ViewState["orgtitle"]%></a>
|
||||||
|
- <a href="<%= Url.RouteUrl("Default", new {controller = "Home" , action = "Index" }) %>"><%= YavscHelpers.SiteName %></a>
|
||||||
|
</h1>
|
||||||
|
</asp:ContentPlaceHolder>
|
||||||
|
<asp:ContentPlaceHolder ID="header" runat="server"></asp:ContentPlaceHolder>
|
||||||
|
<div id="notifications"></div>
|
||||||
|
<% if (ViewData ["Notifications"]!=null) { %>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
<% foreach (Notification note in (IEnumerable<Notification>) ViewData ["Notifications"] ) {
|
||||||
|
if (note.click_action == null) {%> Yavsc.notice(<%=note.body%>); <% }
|
||||||
|
else {%> Yavsc.notice(<%=note.body%>, <%=note.click_action%>); <% } %>
|
||||||
|
<% } %>
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<% } %>
|
||||||
|
</header>
|
||||||
|
<nav data-type="background" data-speed="5">
|
||||||
|
<% if (Membership.GetUser()==null) { %>
|
||||||
|
<a href="<%= Url.RouteUrl("Default", new { controller = "Account", action = "Login", returnUrl=Request.Url.PathAndQuery}) %>" class="menuitem" accesskey = "C">
|
||||||
|
<i class="fa fa-sign-in">Connexion</i>
|
||||||
|
</a>
|
||||||
|
<% } else { %>
|
||||||
|
<ul>
|
||||||
|
<li><%= Html.ActionLink("Backups","Backups") %></li>
|
||||||
|
<li><%= Html.ActionLink("Restaurations", "Restore") %></li>
|
||||||
|
<li><%= Html.ActionLink("Create backup","CreateBackup") %></li>
|
||||||
|
<li><%= Html.ActionLink("Remove user", "RemoveUser") %></li>
|
||||||
|
<li><%= Html.ActionLink("Add a Role ", "AddRole") %></li>
|
||||||
|
<li><%= Html.ActionLink("Remove role", "RemoveRoleQuery") %></li>
|
||||||
|
<li><%= Html.ActionLink("User list", "UserList") %></li>
|
||||||
|
<li><%= Html.ActionLink("Role list", "RoleList") %></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<a href="<%=Url.RouteUrl("Blogs", new { user = HttpContext.Current.User.Identity.Name } )%>" accesskey = "B" class="menuitem" >
|
||||||
|
<img src="<%=Url.AvatarUrl(HttpContext.Current.User.Identity.Name)%>" alt="vos billets" class="iconsmall" />
|
||||||
|
<span class="hint">Vos billets</span>
|
||||||
|
</a>
|
||||||
|
<a href="<%= Url.RouteUrl("Default", new { controller = "Account", action = "Profile", id = HttpContext.Current.User.Identity.Name} ) %>" accesskey="P" class="menuitem fa fa-user">
|
||||||
|
<%= HttpContext.Current.User.Identity.Name %>
|
||||||
|
<span class="hint"> Édition de votre profile </span>
|
||||||
|
</a>
|
||||||
|
<a href="/Blogs/Post" accesskey="P" class="menuitem fa fa-pencil">
|
||||||
|
<u>P</u>oster
|
||||||
|
<span class="hint">Édition d'un nouveau billet </span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href="<%= Url.RouteUrl("Default", new { controller = "Account", action = "Logout", returnUrl=Request.Url.PathAndQuery}) %>" accesskey = "C" class="menuitem fa fa-sign-out">
|
||||||
|
<%=Html.Translate("Logout")%></a>
|
||||||
|
<% } %>
|
||||||
|
</nav>
|
||||||
|
<main data-type="background" data-speed="10" data-emheight="10" data-posx="0" data-posy="22" >
|
||||||
|
<asp:ContentPlaceHolder ID="MainContent" runat="server">
|
||||||
|
</asp:ContentPlaceHolder>
|
||||||
|
</main>
|
||||||
|
<asp:ContentPlaceHolder ID="MASContent" runat="server">
|
||||||
|
</asp:ContentPlaceHolder>
|
||||||
|
<footer data-type="background" data-speed="5" >
|
||||||
|
<div id="copyr">
|
||||||
|
<a href="http://yavsc.pschneider.fr/Blogs/UserPost/paul/License">© 2015 GNU GENERAL PUBLIC LICENSE <i>Version 3, 29 June 2007</i></a>
|
||||||
|
</div>
|
||||||
|
<%= Html.ActionLink("Formulaire de contact","Contact","Home",null, new { @class="thanks" }) %>
|
||||||
|
<% foreach ( Link link in Html.Thanks()) { %>
|
||||||
|
<a class="thanks" href="<%=link.Url%>"><% if (link.Image !=null) {
|
||||||
|
%><img src="<%= link.Image %>" alt="<%= link.Text %>"/></a>
|
||||||
|
<% } else { %>
|
||||||
|
<a class="thanks" href="<%=link.Url%>"><%= link.Text %></a>
|
||||||
|
<% }} %>
|
||||||
|
</footer><div class="modal"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,69 @@
|
|||||||
|
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<% ViewState["orgtitle"] = Html.Translate(Page.Title); %>
|
||||||
|
<% Page.Title = ViewState["orgtitle"] + " - " + YavscHelpers.SiteName; %>
|
||||||
|
<asp:ContentPlaceHolder id="init" runat="server">
|
||||||
|
</asp:ContentPlaceHolder><head runat="server">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<link rel="stylesheet" href="<%=Url.Content("~/App_Themes/style.css")%>" />
|
||||||
|
<link rel="stylesheet" href="<%=Url.Content("~/App_Themes/font-awesome.css")%>" />
|
||||||
|
<link rel="stylesheet" href="<%=Url.Content("~/App_Themes/jquery-ui.css")%>" />
|
||||||
|
<link rel="stylesheet" href="<%=Url.Content("~/App_Themes/prettify.css")%>" />
|
||||||
|
<link rel="stylesheet" href="<%=Url.Content("~/App_Themes/doxy.css")%>" />
|
||||||
|
<link rel="icon" type="image/png" href="/favicon.png?v=3" />
|
||||||
|
<script src="<%=Url.Content("~/Scripts/jquery-2.1.4.min.js")%>"></script>
|
||||||
|
<script src="<%=Url.Content("~/Scripts/jquery-ui-1.11.4.js")%>"></script>
|
||||||
|
<script src="<%=Url.Content("~/Scripts/parallax.js")%>"></script>
|
||||||
|
<script src="<%=Url.Content("~/Scripts/Prettify/run_prettify.js")%>"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var apiBaseUrl = '<%=Url.Content(Yavsc.WebApiConfig.UrlPrefixRelative)%>';
|
||||||
|
</script>
|
||||||
|
<script src="<%=Url.Content("~/Scripts/yavsc.js")%>"></script>
|
||||||
|
<script src="<%=Url.Content("~/Scripts/yavsc.tags.js")%>"></script>
|
||||||
|
<asp:ContentPlaceHolder id="head" runat="server">
|
||||||
|
</asp:ContentPlaceHolder>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header data-type="background" data-speed="8" >
|
||||||
|
<asp:ContentPlaceHolder ID="overHeaderOne" runat="server">
|
||||||
|
<h1><a href="<%= Url.RouteUrl("Default") %>">
|
||||||
|
<%=ViewState["orgtitle"]%></a>
|
||||||
|
- <a href="<%= Url.RouteUrl("Default", new {controller = "Home" , action = "Index" }) %>"><%= YavscHelpers.SiteName %></a>
|
||||||
|
</h1>
|
||||||
|
</asp:ContentPlaceHolder>
|
||||||
|
<asp:ContentPlaceHolder ID="header" runat="server"></asp:ContentPlaceHolder>
|
||||||
|
<div id="notifications"></div>
|
||||||
|
<% if (ViewData ["Notifications"]!=null) { %>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
<% foreach (Notification note in (IEnumerable<Notification>) ViewData ["Notifications"] ) {
|
||||||
|
if (note.click_action == null) {%> Yavsc.notice(<%=note.body%>); <% }
|
||||||
|
else {%> Yavsc.notice(<%=note.body%>, <%=note.click_action%>); <% } %>
|
||||||
|
<% } %>
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<% } %>
|
||||||
|
</header>
|
||||||
|
<main data-type="background" data-speed="10" data-emheight="10" data-posx="0" data-posy="22" >
|
||||||
|
<asp:ContentPlaceHolder ID="MainContent" runat="server">
|
||||||
|
</asp:ContentPlaceHolder>
|
||||||
|
</main>
|
||||||
|
<asp:ContentPlaceHolder ID="MASContent" runat="server">
|
||||||
|
</asp:ContentPlaceHolder>
|
||||||
|
<footer data-type="background" data-speed="5" >
|
||||||
|
<div id="copyr">
|
||||||
|
<a href="http://yavsc.pschneider.fr/Blogs/UserPost/paul/License">© 2015 GNU GENERAL PUBLIC LICENSE <i>Version 3, 29 June 2007</i></a>
|
||||||
|
</div>
|
||||||
|
<%= Html.ActionLink("Formulaire de contact","Contact","Home",null, new { @class="thanks" }) %>
|
||||||
|
<% foreach ( Link link in Html.Thanks()) { %>
|
||||||
|
<a class="thanks" href="<%=link.Url%>"><% if (link.Image !=null) {
|
||||||
|
%><img src="<%= link.Image %>" alt="<%= link.Text %>"/></a>
|
||||||
|
<% } else { %>
|
||||||
|
<a class="thanks" href="<%=link.Url%>"><%= link.Text %></a>
|
||||||
|
<% }} %>
|
||||||
|
</footer><div class="modal"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
Votre compte <%SiteName%> a été créé, votre nom d'utilisateur
|
||||||
|
est <%UserName%>.
|
||||||
|
|
||||||
|
Pour l'activer, veuillez suivre le lien suivant :
|
||||||
|
|
||||||
|
<%UserActivatonUrl%>
|
||||||
|
|
||||||
|
Merci d'avoir créé un compte utilisateur.
|
@ -0,0 +1,41 @@
|
|||||||
|
using System;
|
||||||
|
using System.Configuration;
|
||||||
|
|
||||||
|
namespace Yavsc
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Thanks configuration collection.
|
||||||
|
/// Imlements the configuration,
|
||||||
|
/// providing the thanks collection
|
||||||
|
/// </summary>
|
||||||
|
public class ThanksConfigurationCollection : ConfigurationElementCollection
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the element key.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The element key.</returns>
|
||||||
|
/// <param name="element">Element.</param>
|
||||||
|
protected override object GetElementKey (ConfigurationElement element)
|
||||||
|
{
|
||||||
|
return ((ThanksConfigurationElement) element).Name;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the new element.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The new element.</returns>
|
||||||
|
protected override ConfigurationElement CreateNewElement ()
|
||||||
|
{
|
||||||
|
return new ThanksConfigurationElement();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the element.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The element.</returns>
|
||||||
|
/// <param name="name">Name.</param>
|
||||||
|
public ThanksConfigurationElement GetElement (string name)
|
||||||
|
{
|
||||||
|
return this.BaseGet(name) as ThanksConfigurationElement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
|||||||
|
using System;
|
||||||
|
using System.Configuration;
|
||||||
|
|
||||||
|
namespace Yavsc
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Thanks configuration element.
|
||||||
|
/// </summary>
|
||||||
|
public class ThanksConfigurationElement : ConfigurationElement
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the name.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The name.</value>
|
||||||
|
[ConfigurationProperty("name", IsKey=true, IsRequired=true)]
|
||||||
|
public string Name {
|
||||||
|
get {
|
||||||
|
return (string) base ["name"];
|
||||||
|
}
|
||||||
|
set { base ["name"] = value; }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the URL.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The URL.</value>
|
||||||
|
[ConfigurationProperty("url")]
|
||||||
|
public string Url {
|
||||||
|
get {
|
||||||
|
return (string) base ["url"];
|
||||||
|
}
|
||||||
|
set { base ["url"] = value; }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the image.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The image.</value>
|
||||||
|
[ConfigurationProperty("image")]
|
||||||
|
public string Image {
|
||||||
|
get {
|
||||||
|
return (string) base ["image"];
|
||||||
|
}
|
||||||
|
set { base ["image"] = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the display.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The displaied text when no image is provided and we
|
||||||
|
/// don't want use the name attribute.
|
||||||
|
/// </value>
|
||||||
|
[ConfigurationProperty("display")]
|
||||||
|
public string Display {
|
||||||
|
get {
|
||||||
|
return (string) base ["display"];
|
||||||
|
}
|
||||||
|
set { base ["display"] = value; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
|||||||
|
using System;
|
||||||
|
using System.Configuration;
|
||||||
|
|
||||||
|
namespace Yavsc
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Thanks configuration section.
|
||||||
|
/// </summary>
|
||||||
|
public class ThanksConfigurationSection : ConfigurationSection
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets to.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>To.</value>
|
||||||
|
[ConfigurationProperty("to")]
|
||||||
|
public ThanksConfigurationCollection To {
|
||||||
|
get {
|
||||||
|
return (ThanksConfigurationCollection) this["to"];
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this ["to"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the html class.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The html class.</value>
|
||||||
|
[ConfigurationProperty("html_class")]
|
||||||
|
public string HtmlClass {
|
||||||
|
get {
|
||||||
|
return (string)this ["html_class"];
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this ["html_class"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the title format.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The title format.</value>
|
||||||
|
[ConfigurationProperty("title_format")]
|
||||||
|
public string TitleFormat {
|
||||||
|
get {
|
||||||
|
return (string)this ["title_format"];
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this ["title_format"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
|||||||
|
<%@ Page Title="Change your Password" Language="C#" Inherits="System.Web.Mvc.ViewPage<ChangePasswordModel>" MasterPageFile="~/Models/App.master" %>
|
||||||
|
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
|
||||||
|
<%= Html.ValidationSummary("Modification de mot de passe") %>
|
||||||
|
<% using(Html.BeginForm("ChangePassword", "Account")) { %>
|
||||||
|
<label for="UserName">User Name:</label>
|
||||||
|
<%= Html.TextBox( "UserName" ) %>
|
||||||
|
<%= Html.ValidationMessage("UserName", "*") %><br/>
|
||||||
|
<label for="OldPassword">Old password:</label>
|
||||||
|
<%= Html.Password( "OldPassword" ) %>
|
||||||
|
<%= Html.ValidationMessage("OldPassword", "*") %><br/>
|
||||||
|
<label for="NewPassword">New password:</label>
|
||||||
|
<%= Html.Password( "NewPassword" ) %>
|
||||||
|
<%= Html.ValidationMessage("NewPassword", "*") %><br/>
|
||||||
|
<label for="ConfirmPassword">Confirm password:</label>
|
||||||
|
<%= Html.Password( "ConfirmPassword" ) %>
|
||||||
|
<%= Html.ValidationMessage("ConfirmPassword", "*") %>
|
||||||
|
<input type="submit"/>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
</asp:Content>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
<%@ Page Title="Successfully changed your password" Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Models/App.master" %>
|
||||||
|
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
|
||||||
|
<div>
|
||||||
|
<%= Html.ActionLink("Register","Register")%></div>
|
||||||
|
<div><%= Html.ActionLink("ChangePassword","ChangePassword")%></div>
|
||||||
|
</asp:Content>
|
@ -0,0 +1,74 @@
|
|||||||
|
<%@ Page Title="Circles" Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage" %>
|
||||||
|
<%@ Register Assembly="Yavsc.WebControls" TagPrefix="yavsc" Namespace="Yavsc.WebControls" %>
|
||||||
|
<asp:Content ID="headContent" ContentPlaceHolderID="head" runat="server">
|
||||||
|
<script type="text/javascript" src="<%=Url.Content("~/Scripts/stupidtable.js")%>"></script>
|
||||||
|
</asp:Content>
|
||||||
|
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||||
|
|
||||||
|
<table id="tbc">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th data-sort="string"><%=Html.Translate("Title")%>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<style>
|
||||||
|
.btnselcircle { cursor: pointer; }
|
||||||
|
</style>
|
||||||
|
<tbody id="tbcb">
|
||||||
|
<% int lc=0;
|
||||||
|
foreach (var ci in (IEnumerable<CircleBase>) ViewData["Circles"]) { lc++; %>
|
||||||
|
<tr class="<%= (lc%2==0)?"even ":"odd " %>row" id="c_<%=ci.Id%>">
|
||||||
|
<td cid="<%=ci.Id%>" class="btnselcircle"><%=ci.Title%></td>
|
||||||
|
<td><input type="button" value="<%=Html.Translate("Remove")%>"
|
||||||
|
class="btnremovecircle actionlink" cid="<%=ci.Id%>"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% } %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="actionlink" id="btednvcirc" did="fncirc">Ajouter un cercle</div>
|
||||||
|
<script>
|
||||||
|
$(function(){
|
||||||
|
$("#tbc").stupidtable();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</asp:Content>
|
||||||
|
<asp:Content ID="MASContentContent" ContentPlaceHolderID="MASContent" runat="server">
|
||||||
|
<div id="fncirc" class="hidden">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="panel">
|
||||||
|
<form>
|
||||||
|
<fieldset>
|
||||||
|
<legend id="lgdnvcirc"></legend>
|
||||||
|
|
||||||
|
<label for="title"><b><%=Html.Translate("Title")%></b></label>
|
||||||
|
<input type="text" id="title" name="title" class="inputtext" onchange="onCircleChanged"/>
|
||||||
|
<span id="Err_cr_title" class="field-validation-valid error"></span>
|
||||||
|
|
||||||
|
<input type="button" id="btnnewcircle"
|
||||||
|
value="<%=Html.Translate("Create")%>" class="actionlink rowbtnct" />
|
||||||
|
<input type="button" id="btneditcircle"
|
||||||
|
value="<%=Html.Translate("Modify")%>" class="actionlink rowbtnct" />
|
||||||
|
<input type="hidden" name="id" id="id" />
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript" src="<%=Url.Content("~/Scripts/yavsc.circles.js")%>" >
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
$('#btednvcirc').click(editNewCircle);
|
||||||
|
$("#btnnewcircle").click(addCircle);
|
||||||
|
$("#btneditcircle").click(modifyCircle);
|
||||||
|
$(".btnremovecircle").click(removeCircle);
|
||||||
|
$(".btnselcircle").click(selectCircle);
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</asp:Content>
|
@ -0,0 +1,4 @@
|
|||||||
|
<%@ Page Title="Comptes utilisateur" Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Models/App.master" %>
|
||||||
|
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
|
||||||
|
Pas de contenu :-(
|
||||||
|
</asp:Content>
|
@ -0,0 +1,32 @@
|
|||||||
|
<%@ Page Title="Login" Language="C#" Inherits="System.Web.Mvc.ViewPage<LoginModel>" MasterPageFile="~/Models/NoLogin.master" %>
|
||||||
|
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
|
||||||
|
<div class="panel">
|
||||||
|
<%= Html.ValidationSummary("Ouverture de session") %>
|
||||||
|
<% using(Html.BeginForm("Login", "Account")) %>
|
||||||
|
<% { %>
|
||||||
|
<%= Html.LabelFor(model => model.UserName) %>
|
||||||
|
<%= Html.TextBox( "UserName" ) %>
|
||||||
|
<%= Html.ValidationMessage("UserName", "*") %><br/>
|
||||||
|
|
||||||
|
<%= Html.LabelFor(model => model.Password) %>
|
||||||
|
<%= Html.Password( "Password" ) %>
|
||||||
|
<%= Html.ValidationMessage("Password", "*") %><br/>
|
||||||
|
|
||||||
|
<%= Html.LabelFor(model => model.RememberMe) %>
|
||||||
|
<%= Html.CheckBox("RememberMe") %>
|
||||||
|
<%= Html.ValidationMessage("RememberMe", "") %><br/>
|
||||||
|
<%= Html.Hidden("returnUrl",ViewData["returnUrl"]) %>
|
||||||
|
<%= Html.AntiForgeryToken() %>
|
||||||
|
<!-- Html.AntiForgeryToken() -->
|
||||||
|
<input type="submit"/>
|
||||||
|
<% } %></div>
|
||||||
|
<div class="panel">
|
||||||
|
<%= Html.ActionLink("S'enregistrer","GetRegister",new {returnUrl=ViewData["returnUrl"]}, new { @class="actionlink" }) %>
|
||||||
|
</div>
|
||||||
|
<div class="panel">
|
||||||
|
<a href="<%= Url.RouteUrl ("Default", new { controller = "Google", action= "Login", returnUrl=ViewData["returnUrl"] }) %>" class="actionlink">
|
||||||
|
Identification avec un compte Google
|
||||||
|
<img src="/App_Themes/images/sign-in-with-google.png" style="max-height:1.5em; max-width:6em;" alt="Google sign in">
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</asp:Content>
|
@ -0,0 +1,140 @@
|
|||||||
|
<%@ Page Title="Profile_edition" Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage<ProfileEdition>" %>
|
||||||
|
|
||||||
|
<asp:Content ContentPlaceHolderID="init" ID="init1" runat="server">
|
||||||
|
<% Title = ViewData["UserName"] + " : " +Html.Translate("Profile_edition"); %>
|
||||||
|
</asp:Content>
|
||||||
|
|
||||||
|
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||||
|
<style>
|
||||||
|
table.layout { border-width: 0; }
|
||||||
|
table.layout TR TD { max-width:40%; }
|
||||||
|
</style>
|
||||||
|
<%= Html.ValidationSummary() %>
|
||||||
|
<% using(Html.BeginForm("Profile", "Account", FormMethod.Post, new { enctype = "multipart/form-data" })) %>
|
||||||
|
<% { %>
|
||||||
|
|
||||||
|
<%= Html.Hidden("UserName",ViewData["ProfileUserName"]) %>
|
||||||
|
|
||||||
|
<fieldset><legend>Informations publiques</legend>
|
||||||
|
|
||||||
|
|
||||||
|
<%= Html.LabelFor(model => model.NewUserName) %> :
|
||||||
|
<%= Html.TextBox("NewUserName") %>
|
||||||
|
<%= Html.ValidationMessage("NewUserName", "*") %>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<%= Html.LabelFor(model => model.WebSite) %> :
|
||||||
|
<%= Html.TextBox("WebSite") %>
|
||||||
|
<%= Html.ValidationMessage("WebSite", "*") %>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
Avatar : <img src="<%=Url.AvatarUrl(HttpContext.Current.User.Identity.Name)%>" alt="avatar" class="iconsmall" />
|
||||||
|
|
||||||
|
<input type="file" id="AvatarFile" name="AvatarFile"/>
|
||||||
|
<%= Html.ValidationMessage("AvatarFile", "*") %>
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
<fieldset><legend>Informations administratives</legend>
|
||||||
|
<%= Html.LabelFor(model => model.Name) %> :
|
||||||
|
<%= Html.TextBox("Name") %>
|
||||||
|
<%= Html.ValidationMessage("Name", "*") %>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset><legend>Blog</legend>
|
||||||
|
<div class="spanel">
|
||||||
|
<%= Html.LabelFor(model => model.BlogVisible) %> :
|
||||||
|
<%= Html.CheckBox("BlogVisible") %>
|
||||||
|
<%= Html.ValidationMessage("BlogVisible", "*") %>
|
||||||
|
</div><div class="spanel">
|
||||||
|
|
||||||
|
<%= Html.LabelFor(model => model.BlogTitle) %> :
|
||||||
|
<%= Html.TextBox("BlogTitle") %>
|
||||||
|
<%= Html.ValidationMessage("BlogTitle", "*") %>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset><legend>Contact</legend>
|
||||||
|
<div class="spanel">
|
||||||
|
<%= Html.LabelFor(model => model.Phone) %>
|
||||||
|
<%= Html.TextBox("Phone") %>
|
||||||
|
<%= Html.ValidationMessage("Phone", "*") %>
|
||||||
|
</div><div class="spanel">
|
||||||
|
<%= Html.LabelFor(model => model.Mobile) %>
|
||||||
|
<%= Html.TextBox("Mobile") %>
|
||||||
|
<%= Html.ValidationMessage("Mobile", "*") %>
|
||||||
|
</div><div class="spanel">
|
||||||
|
<%= Html.LabelFor(model => model.Address) %>
|
||||||
|
<%= Html.TextBox("Address") %>
|
||||||
|
<%= Html.ValidationMessage("Address", "*") %>
|
||||||
|
</div><div class="spanel">
|
||||||
|
<%= Html.LabelFor(model => model.CityAndState) %>
|
||||||
|
<%= Html.TextBox("CityAndState") %>
|
||||||
|
<%= Html.ValidationMessage("CityAndState", "*") %>
|
||||||
|
</div><div class="spanel">
|
||||||
|
<%= Html.LabelFor(model => model.ZipCode) %>
|
||||||
|
<%= Html.TextBox("ZipCode") %>
|
||||||
|
<%= Html.ValidationMessage("ZipCode", "*") %>
|
||||||
|
</div><div class="spanel">
|
||||||
|
<%= Html.LabelFor(model => model.Country) %>
|
||||||
|
<%= Html.TextBox("Country") %>
|
||||||
|
<%= Html.ValidationMessage("Country", "*") %>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset><legend>Disponibilité</legend>
|
||||||
|
<div class="spanel">
|
||||||
|
<%= Html.LabelFor(model => model.GoogleCalendar) %> :
|
||||||
|
|
||||||
|
<%= Html.Encode(Model.GoogleCalendar) %>
|
||||||
|
<%= Html.ActionLink("Choisir l'agenda","ChooseCalendar","Google",new { returnUrl= Request.Url.AbsolutePath }, new { @class="actionlink" }) %>
|
||||||
|
</div></fieldset>
|
||||||
|
<fieldset><legend>Informations de facturation</legend>
|
||||||
|
|
||||||
|
<div class="spanel">
|
||||||
|
<%= Html.LabelFor(model => model.BankCode) %> :
|
||||||
|
<%= Html.TextBox("BankCode") %>
|
||||||
|
<%= Html.ValidationMessage("BankCode", "*") %>
|
||||||
|
</div><div class="spanel">
|
||||||
|
|
||||||
|
<%= Html.LabelFor(model => model.WicketCode) %> :
|
||||||
|
<%= Html.TextBox("WicketCode") %>
|
||||||
|
<%= Html.ValidationMessage("WicketCode", "*") %>
|
||||||
|
</div><div class="spanel">
|
||||||
|
|
||||||
|
<%= Html.LabelFor(model => model.AccountNumber) %> :
|
||||||
|
<%= Html.TextBox("AccountNumber") %>
|
||||||
|
<%= Html.ValidationMessage("AccountNumber", "*") %>
|
||||||
|
</div><div class="spanel">
|
||||||
|
<%= Html.LabelFor(model => model.BankedKey) %> :
|
||||||
|
<%= Html.TextBox("BankedKey") %>
|
||||||
|
<%= Html.ValidationMessage("BankedKey", "*") %>
|
||||||
|
</div><div class="spanel">
|
||||||
|
<%= Html.LabelFor(model => model.BIC) %> :
|
||||||
|
<%= Html.TextBox("BIC") %>
|
||||||
|
<%= Html.ValidationMessage("BIC", "*") %>
|
||||||
|
</div><div class="spanel">
|
||||||
|
<%= Html.LabelFor(model => model.IBAN) %> :
|
||||||
|
<%= Html.TextBox("IBAN") %>
|
||||||
|
<%= Html.ValidationMessage("IBAN", "*") %>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<input type="submit"/>
|
||||||
|
<% } %>
|
||||||
|
<aside>
|
||||||
|
<%= Html.ActionLink("Changer de mot de passe","ChangePassword", "Account",null, new { @class="actionlink" })%>
|
||||||
|
<%= Html.ActionLink("Désincription", "Unregister", "Account", new { id = ViewData["UserName"] } , new { @class="actionlink" })%>
|
||||||
|
</aside>
|
||||||
|
<aside>
|
||||||
|
<% if (Roles.IsUserInRole((string)ViewData ["UserName"],"Admin")) { %>
|
||||||
|
This user is Admin.
|
||||||
|
<% } %>
|
||||||
|
<code>HasBankAccount:<%= Model.HasBankAccount %></code>
|
||||||
|
<% if (!Model.HasBankAccount) { %><span class="hint">
|
||||||
|
IBAN+BIC ou Codes banque, guichet, compte et clé RIB</span>
|
||||||
|
<% } %>, <code>IsBillable:<%=Model.IsBillable%></code>
|
||||||
|
<% if (!Model.IsBillable) { %>
|
||||||
|
<span class="hint">un nom et au choix, une adresse postale valide,
|
||||||
|
ou un téléphone, ou un email, ou un Mobile</span> <% } %>
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
</asp:Content>
|
||||||
|
|
@ -0,0 +1,73 @@
|
|||||||
|
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<RegisterClientModel>" %>
|
||||||
|
<%= Html.ValidationSummary() %>
|
||||||
|
<% using(Html.BeginForm("Register")) %>
|
||||||
|
<% { %>
|
||||||
|
<h1>Nouvel utilisateur</h1>
|
||||||
|
<span class="field-validation-valid error" data-valmsg-replace="false" id="Err_ur_IsApprouved">*</span>
|
||||||
|
<table class="layout">
|
||||||
|
|
||||||
|
<tr><td align="right">
|
||||||
|
<%= Html.LabelFor(model => model.Name) %>
|
||||||
|
</td><td>
|
||||||
|
<%= Html.TextBox( "Name" ) %>
|
||||||
|
<%= Html.ValidationMessage("Name", "*", new { @id="Err_ur_Name", @class="error" }) %></td></tr>
|
||||||
|
|
||||||
|
<tr><td align="right">
|
||||||
|
<%= Html.LabelFor(model => model.UserName) %>
|
||||||
|
</td><td>
|
||||||
|
<%= Html.TextBox( "UserName" ) %>
|
||||||
|
<%= Html.ValidationMessage("UserName", "*", new { @id="Err_ur_UserName", @class="error" }) %></td></tr>
|
||||||
|
<tr><td align="right">
|
||||||
|
<%= Html.LabelFor(model => model.Password) %>
|
||||||
|
</td><td>
|
||||||
|
<%= Html.Password( "Password" ) %>
|
||||||
|
<%= Html.ValidationMessage("Password", "*", new { @id="Err_ur_Password", @class="error" }) %>
|
||||||
|
</td></tr>
|
||||||
|
<tr><td align="right">
|
||||||
|
<%= Html.LabelFor(model => model.Email) %>
|
||||||
|
</td><td>
|
||||||
|
<%= Html.TextBox( "Email" ) %>
|
||||||
|
<%= Html.ValidationMessage("Email", "*", new { @id="Err_ur_Email", @class="error" }) %>
|
||||||
|
</td></tr>
|
||||||
|
|
||||||
|
<tr><td align="right">
|
||||||
|
<%= Html.LabelFor(model => model.Address) %>
|
||||||
|
</td><td>
|
||||||
|
<%= Html.TextBox( "Address" ) %>
|
||||||
|
<%= Html.ValidationMessage("Address", "*", new { @id="Err_ur_Address", @class="error" }) %></td></tr>
|
||||||
|
|
||||||
|
<tr><td align="right">
|
||||||
|
<%= Html.LabelFor(model => model.CityAndState) %>
|
||||||
|
</td><td>
|
||||||
|
<%= Html.TextBox( "CityAndState" ) %>
|
||||||
|
<%= Html.ValidationMessage("CityAndState", "*", new { @id="Err_ur_CityAndState", @class="error" }) %>
|
||||||
|
|
||||||
|
|
||||||
|
</td></tr>
|
||||||
|
|
||||||
|
<tr><td align="right">
|
||||||
|
<%= Html.LabelFor(model => model.ZipCode) %>
|
||||||
|
</td><td>
|
||||||
|
<%= Html.TextBox( "ZipCode" ) %>
|
||||||
|
<%= Html.ValidationMessage("ZipCode", "*", new { @id="Err_ur_ZipCode", @class="error" }) %></td></tr>
|
||||||
|
|
||||||
|
|
||||||
|
<tr><td align="right">
|
||||||
|
<%= Html.LabelFor(model => model.Phone) %>
|
||||||
|
</td><td>
|
||||||
|
<%= Html.TextBox( "Phone" ) %>
|
||||||
|
<%= Html.ValidationMessage("Phone", "*", new { @id="Err_ur_Phone", @class="error" }) %></td></tr>
|
||||||
|
|
||||||
|
<tr><td align="right">
|
||||||
|
<%= Html.LabelFor(model => model.Mobile) %>
|
||||||
|
</td><td>
|
||||||
|
<%= Html.TextBox( "Mobile" ) %>
|
||||||
|
<%= Html.ValidationMessage("Mobile", "*", new { @id="Err_ur_Mobile", @class="error" }) %></td></tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
<input type="button" id="btnnewuser" class="actionlink" value="Enregistrer">
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
|||||||
|
<%@ Page Title="Register" Language="C#" Inherits="System.Web.Mvc.ViewPage<RegisterViewModel>" MasterPageFile="~/Models/App.master" %>
|
||||||
|
|
||||||
|
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
|
||||||
|
<%= Html.ValidationSummary() %>
|
||||||
|
<% using(Html.BeginForm("Register", "Account")) %>
|
||||||
|
<% { %>
|
||||||
|
<table class="layout">
|
||||||
|
<tr><td align="right">
|
||||||
|
<%= Html.LabelFor(model => model.UserName) %>
|
||||||
|
</td><td>
|
||||||
|
<%= Html.TextBox( "UserName" ) %>
|
||||||
|
<%= Html.ValidationMessage("UserName", "*") %></td></tr>
|
||||||
|
<tr><td align="right">
|
||||||
|
<%= Html.LabelFor(model => model.Password) %>
|
||||||
|
</td><td>
|
||||||
|
<%= Html.Password( "Password" ) %>
|
||||||
|
<%= Html.ValidationMessage("Password", "*") %>
|
||||||
|
</td></tr>
|
||||||
|
<tr><td align="right">
|
||||||
|
<%= Html.LabelFor(model => model.ConfirmPassword) %>
|
||||||
|
</td><td>
|
||||||
|
<%= Html.Password( "ConfirmPassword" ) %>
|
||||||
|
<%= Html.ValidationMessage("ConfirmPassword", "*") %>
|
||||||
|
</td></tr>
|
||||||
|
<tr><td align="right">
|
||||||
|
<%= Html.LabelFor(model => model.Email) %>
|
||||||
|
</td><td>
|
||||||
|
<%= Html.TextBox( "Email" ) %>
|
||||||
|
<%= Html.ValidationMessage("Email", "*") %>
|
||||||
|
</td></tr>
|
||||||
|
</table>
|
||||||
|
<br/>
|
||||||
|
<%= Html.Hidden("returnUrl",ViewData["returnUrl"]) %>
|
||||||
|
|
||||||
|
<input type="submit"/>
|
||||||
|
<% } %>
|
||||||
|
</asp:Content>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
|||||||
|
<%@ Page Title="Comptes utilisateur" Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Models/App.master" %>
|
||||||
|
|
||||||
|
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
|
||||||
|
Votre compte utilisateur
|
||||||
|
<%= Html.Encode(YavscHelpers.SiteName) %>
|
||||||
|
a été créé, un e-mail de validation de votre compte a été envoyé a l'adresse fournie:<br/>
|
||||||
|
<<%= Html.Encode(ViewData["email"]) %>>.<br/>
|
||||||
|
Vous devriez le recevoir rapidement.<br/>
|
||||||
|
Pour valider votre compte, suivez le lien indiqué dans cet e-mail.
|
||||||
|
<div>
|
||||||
|
<a class="actionlink" href="<%=ViewData["returnUrl"]%>">Retour</a>
|
||||||
|
</div>
|
||||||
|
</asp:Content>
|
@ -0,0 +1,23 @@
|
|||||||
|
<%@ Page Title="Reset your Password" Language="C#" Inherits="System.Web.Mvc.ViewPage<LostPasswordModel>" MasterPageFile="~/Models/App.master" %>
|
||||||
|
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
|
||||||
|
<%= Html.ValidationSummary("Modification de mot de passe") %>
|
||||||
|
|
||||||
|
<% using(Html.BeginForm("ResetPassword", "Account")) { %>
|
||||||
|
Enter one of the following : <br/>
|
||||||
|
<ul><li>
|
||||||
|
<label for="UserName">Your user name (login):</label>
|
||||||
|
<%= Html.TextBox( "UserName" ) %>
|
||||||
|
<%= Html.ValidationMessage("UserName", "*") %></li>
|
||||||
|
<li>
|
||||||
|
<label for="Email">The e-mail address you used to register here:</label>
|
||||||
|
<%= Html.TextBox( "Email" ) %>
|
||||||
|
<%= Html.ValidationMessage("Email", "*") %>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
Then, hit the following button:
|
||||||
|
<input type="submit" value="I lost my password!"/> <br/>
|
||||||
|
A message will be sent to you, containning a link that you'll can use to reset your password.
|
||||||
|
<% } %>
|
||||||
|
</asp:Content>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
|||||||
|
<%@ Page Title="Comptes utilisateur - Validation" Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Models/App.master" %>
|
||||||
|
<!-- tout est dans le message du modèle App.master ViewData["Message"] -->
|
@ -0,0 +1,15 @@
|
|||||||
|
<%@ Page Title="Ajout d'un role" Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Models/AppAdmin.master" %>
|
||||||
|
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
|
||||||
|
|
||||||
|
<%= Html.ValidationSummary() %>
|
||||||
|
<% using(Html.BeginForm())
|
||||||
|
{ %>
|
||||||
|
Nom du rôle :
|
||||||
|
<%= Html.TextBox( "RoleName" ) %>
|
||||||
|
<%= Html.ValidationMessage("RoleName", "*") %><br/>
|
||||||
|
<input class="actionlink" type="submit"/>
|
||||||
|
<% } %>
|
||||||
|
<%= Html.Partial("AddMemberToRole")%>
|
||||||
|
</asp:Content>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
|||||||
|
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
|
||||||
|
<%= Html.ValidationSummary() %>
|
||||||
|
<% using(Ajax.BeginForm("AddUserToRole", "Admin", new AjaxOptions() { UpdateTargetId = "roleaddedresult" }))
|
||||||
|
{ %>
|
||||||
|
<fieldset>
|
||||||
|
<div id="roleaddedresult"></div>
|
||||||
|
<label for="UserName" >Utilisateur : </label><input type="text" name="UserName" id="UserName">
|
||||||
|
<%= Html.ValidationMessage("UserName", "*") %><br/>
|
||||||
|
<label for="RoleName" >Nom du rôle : </label>
|
||||||
|
<input type="text" name="RoleName" id="RoleName">
|
||||||
|
<%= Html.ValidationMessage("RoleName", "*") %><br/>
|
||||||
|
<%= Ajax.ActionLink("AddUserToRole", "AddUserToRole", new { RoleName = "Admin" } , new AjaxOptions() { UpdateTargetId = "roleaddedresult" }) %>
|
||||||
|
</fieldset>
|
||||||
|
<% } %>
|
@ -0,0 +1,31 @@
|
|||||||
|
<%@ Page Title="Liste des administrateurs" Language="C#" Inherits="System.Web.Mvc.ViewPage<NewAdminModel>" MasterPageFile="~/Models/AppAdmin.master" %>
|
||||||
|
|
||||||
|
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
|
||||||
|
<div>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<% foreach (string u in (string[])ViewData["admins"]) { %>
|
||||||
|
<tr><td>
|
||||||
|
<%= u %> </td><td><%= Html.ActionLink("Remove","RemoveFromRole",new { username = u, rolename="Admin", returnUrl = Request.Url.PathAndQuery })%>
|
||||||
|
</td></tr>
|
||||||
|
|
||||||
|
<% } %>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h2>Ajout d'un administrateur
|
||||||
|
</h2>
|
||||||
|
<p><%= Html.ValidationSummary() %> </p>
|
||||||
|
|
||||||
|
<% using ( Html.BeginForm("Admin", "Admin") ) { %>
|
||||||
|
|
||||||
|
<%= Html.LabelFor(model => model.UserName) %> :
|
||||||
|
<%= Html.DropDownListFor(model => model.UserName, (List<SelectListItem>)ViewData["useritems"] ) %>
|
||||||
|
<%= Html.ValidationMessage("UserName", "*") %>
|
||||||
|
|
||||||
|
<input type="submit"/>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</asp:Content>
|
||||||
|
|
@ -0,0 +1,7 @@
|
|||||||
|
<%@ Page Title="Backup created" Language="C#" MasterPageFile="~/Models/AppAdmin.master" Inherits="System.Web.Mvc.ViewPage<Export>" %>
|
||||||
|
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||||
|
<div><h2>Error message </h2> <%= Html.Encode(Model.Error) %></div>
|
||||||
|
<div><h2>Message </h2> <%= Html.Encode(Model.Message) %></div>
|
||||||
|
<div><h2>File name</h2> <%= Html.Encode(Model.FileName) %></div>
|
||||||
|
<div><h2>Exit Code</h2> <%= Html.Encode(Model.ExitCode) %></div>
|
||||||
|
</asp:Content>
|
@ -0,0 +1,6 @@
|
|||||||
|
<%@ Page Language="C#" MasterPageFile="~/Models/AppAdmin.master" Inherits="System.Web.Mvc.ViewPage<DataAccess>" %>
|
||||||
|
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||||
|
|
||||||
|
<%=Html.ActionLink("Create a database backup", "CreateBackup")%><br/>
|
||||||
|
<%=Html.ActionLink("Restaurations", "Restore")%><br/>
|
||||||
|
</asp:Content>
|
@ -0,0 +1,23 @@
|
|||||||
|
<%@ Page Title="Backup creation" Language="C#" MasterPageFile="~/Models/AppAdmin.master" Inherits="System.Web.Mvc.ViewPage<DataAccess>" %>
|
||||||
|
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||||
|
<%= Html.ValidationSummary("CreateBackup","Admin") %>
|
||||||
|
<% using (Html.BeginForm("CreateBackup")) { %>
|
||||||
|
|
||||||
|
<%= Html.LabelFor(model => model.Host) %>:
|
||||||
|
<%= Html.TextBox( "Host" ) %>
|
||||||
|
<%= Html.ValidationMessage("Host", "*") %><br/>
|
||||||
|
<%= Html.LabelFor(model => model.Port) %>:
|
||||||
|
<%= Html.TextBox( "Port" ) %>
|
||||||
|
<%= Html.ValidationMessage("Port", "*") %><br/>
|
||||||
|
<%= Html.LabelFor(model => model.DbName) %>:
|
||||||
|
<%= Html.TextBox( "DbName" ) %>
|
||||||
|
<%= Html.ValidationMessage("DbName", "*") %><br/>
|
||||||
|
<%= Html.LabelFor(model => model.DbUser) %>:
|
||||||
|
<%= Html.TextBox( "DbUser" ) %>
|
||||||
|
<%= Html.ValidationMessage("DbUser", "*") %><br/>
|
||||||
|
<%= Html.LabelFor(model => model.Password) %>:
|
||||||
|
<%= Html.Password( "Password" ) %>
|
||||||
|
<%= Html.ValidationMessage("Password", "*") %><br/>
|
||||||
|
<input type="submit"/>
|
||||||
|
<% } %>
|
||||||
|
</asp:Content>
|
@ -0,0 +1,12 @@
|
|||||||
|
<%@ Page Title="Db init" Language="C#" MasterPageFile="~/Models/NoLogin.master" Inherits="System.Web.Mvc.ViewPage<TaskOutput>" %>
|
||||||
|
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
|
||||||
|
<h1>Initialisation de la base de données</h1>
|
||||||
|
<div><h2>Error message </h2> <%= Html.Encode(Model.Error) %></div>
|
||||||
|
<div><h2>Message </h2> <%= Html.Encode(Model.Message) %></div>
|
||||||
|
<div><h2>Exit Code</h2> <%= Html.Encode(Model.ExitCode) %></div>
|
||||||
|
<form><fieldset><legend>Acces à la base de donnée</legend>
|
||||||
|
<label>db Name:</label><%= Html.Encode(ViewData["DbName"]) %><br/>
|
||||||
|
<label>db User:</label><%= Html.Encode(ViewData["DbUser"]) %><br/>
|
||||||
|
<label>Hôte:</label><%= Html.Encode(ViewData["Host"]) %></fieldset>
|
||||||
|
</form>
|
||||||
|
</asp:Content>
|
@ -0,0 +1,4 @@
|
|||||||
|
<%@ Page Title="Administration" Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Models/AppAdmin.master" %>
|
||||||
|
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
|
||||||
|
</asp:Content>
|
||||||
|
|
@ -0,0 +1,23 @@
|
|||||||
|
<%@ Page Title="Init db" Language="C#" MasterPageFile="~/Models/NoLogin.master" Inherits="System.Web.Mvc.ViewPage<DataAccess>" %>
|
||||||
|
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||||
|
<%= Html.ValidationSummary("Init a new data base") %>
|
||||||
|
<% using (Html.BeginForm("InitDb","Admin")) { %>
|
||||||
|
<%= Html.LabelFor(model => model.Host) %>:
|
||||||
|
<%= Html.TextBox( "Host" ) %>
|
||||||
|
<%= Html.ValidationMessage("Host", "*") %><br/>
|
||||||
|
<%= Html.LabelFor(model => model.Port) %>:
|
||||||
|
<%= Html.TextBox( "Port" ) %>
|
||||||
|
<%= Html.ValidationMessage("Port", "*") %><br/>
|
||||||
|
<%= Html.LabelFor(model => model.DbName) %>:
|
||||||
|
<%= Html.TextBox( "DbName" ) %>
|
||||||
|
<%= Html.ValidationMessage("DbName", "*") %><br/>
|
||||||
|
<%= Html.LabelFor(model => model.DbUser) %>:
|
||||||
|
<%= Html.TextBox( "DbUser" ) %>
|
||||||
|
<%= Html.ValidationMessage("DbUser", "*") %><br/>
|
||||||
|
<%= Html.LabelFor(model => model.Password) %>:
|
||||||
|
<%= Html.Password( "Password" ) %>
|
||||||
|
<%= Html.ValidationMessage("Password", "*") %><br/>
|
||||||
|
<label for="doInit">Executer le script de création de la base: </label><input type="checkbox" name="doInit" id="doInit" >
|
||||||
|
<input type="submit"/>
|
||||||
|
<% } %>
|
||||||
|
</asp:Content>
|
@ -0,0 +1,17 @@
|
|||||||
|
<%@ Page Title="User removal" Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Models/AppAdmin.master" %>
|
||||||
|
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
|
||||||
|
<div>
|
||||||
|
<%= Html.ValidationSummary() %>
|
||||||
|
<% using ( Html.BeginForm("RemoveRole","Admin") ) { %>
|
||||||
|
Supprimer le rôle
|
||||||
|
<%= Html.Encode( ViewData["roletoremove"] ) %> ?
|
||||||
|
<br/>
|
||||||
|
<input type="hidden" name="rolename" value="<%=ViewData["roletoremove"]%>"/>
|
||||||
|
<input class="actionlink" type="submit" name="submitbutton" value="Supprimer"/>
|
||||||
|
<input class="actionlink" type="submit" name="submitbutton" value="Annuler" />
|
||||||
|
<% } %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</asp:Content>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
|||||||
|
<%@ Page Title="User removal" Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Models/AppAdmin.master" %>
|
||||||
|
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
|
||||||
|
<div>
|
||||||
|
|
||||||
|
<%= Html.ValidationSummary() %>
|
||||||
|
<% using ( Html.BeginForm("RemoveUser","Admin") ) { %>
|
||||||
|
Supprimer l'utilisateur
|
||||||
|
<%= Html.Encode( ViewData["usertoremove"] ) %> ?
|
||||||
|
<br/>
|
||||||
|
<input type="hidden" name="username" value="<%=ViewData["usertoremove"]%>"/>
|
||||||
|
<input class="actionlink" type="submit" name="submitbutton" value="Supprimer"/>
|
||||||
|
<input class="actionlink" type="submit" name="submitbutton" value="Annuler" />
|
||||||
|
<% } %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</asp:Content>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
|||||||
|
<%@ Page Title="Restore" Language="C#" MasterPageFile="~/Models/AppAdmin.master" Inherits="System.Web.Mvc.ViewPage<DataAccess>" %>
|
||||||
|
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||||
|
<%= Html.ValidationSummary("Restore a database backup") %>
|
||||||
|
<% using (Html.BeginForm("Restore","Admin")) { %>
|
||||||
|
|
||||||
|
<% string [] bcfiles = (string[]) ViewData["Backups"]; %>
|
||||||
|
<select name="backupName">
|
||||||
|
<% foreach (string s in bcfiles)
|
||||||
|
{
|
||||||
|
%>
|
||||||
|
<option value="<%=s%>"><%=s%></option>
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
</select>
|
||||||
|
<label for="dataOnly">Data only :</label>
|
||||||
|
<%= Html.CheckBox("dataOnly")%>
|
||||||
|
|
||||||
|
<%= Html.LabelFor(model => model.Host) %>:
|
||||||
|
<%= Html.TextBox( "Host" ) %>
|
||||||
|
<%= Html.ValidationMessage("Host", "*") %><br/>
|
||||||
|
<%= Html.LabelFor(model => model.Port) %>:
|
||||||
|
<%= Html.TextBox( "Port" ) %>
|
||||||
|
<%= Html.ValidationMessage("Port", "*") %><br/>
|
||||||
|
<%= Html.LabelFor(model => model.DbName) %>:
|
||||||
|
<%= Html.TextBox( "DbName" ) %>
|
||||||
|
<%= Html.ValidationMessage("DbName", "*") %><br/>
|
||||||
|
<%= Html.LabelFor(model => model.DbUser) %>:
|
||||||
|
<%= Html.TextBox( "DbUser" ) %>
|
||||||
|
<%= Html.ValidationMessage("DbUser", "*") %><br/>
|
||||||
|
<%= Html.LabelFor(model => model.Password) %>:
|
||||||
|
<%= Html.Password( "Password" ) %>
|
||||||
|
<%= Html.ValidationMessage("Password", "*") %><br/>
|
||||||
|
|
||||||
|
<input type="submit"/>
|
||||||
|
<% } %>
|
||||||
|
</asp:Content>
|
@ -0,0 +1,8 @@
|
|||||||
|
<%@ Page Language="C#" MasterPageFile="~/Models/AppAdmin.master" Inherits="System.Web.Mvc.ViewPage<TaskOutput>" %>
|
||||||
|
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||||
|
<h1><%=Html.Encode(ViewData["BackupName"])%> Restauration</h1>
|
||||||
|
<div><h2>Error message </h2> <%= Html.Encode(Model.Error) %></div>
|
||||||
|
<div><h2>Message </h2> <%= Html.Encode(Model.Message) %></div>
|
||||||
|
<div><h2>Exit Code</h2> <%= Html.Encode(Model.ExitCode) %></div>
|
||||||
|
|
||||||
|
</asp:Content>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue