Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions Kooboo.CMS/Kooboo.CMS.Membership/Services/MembershipUserManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System.Text.RegularExpressions;
using Kooboo.CMS.Common.DataViolation;
using Kooboo.CMS.Membership.OAuthClients;
using Kooboo.Globalization;


namespace Kooboo.CMS.Membership.Services
Expand Down Expand Up @@ -67,11 +68,11 @@ public virtual MembershipUser Create(Kooboo.CMS.Membership.Models.Membership mem
List<DataViolationItem> violations = new List<DataViolationItem>();
if (membershipUser.AsActual() != null)
{
violations.Add(new DataViolationItem("UserName", userName, "DuplicateUserName"));
violations.Add(new DataViolationItem("UserName", userName, "DuplicateUserName".Localize()));
}
if (_provider.QueryUserByEmail(membership, email) != null)
{
violations.Add(new DataViolationItem("Email", email, "DuplicateEmail"));
violations.Add(new DataViolationItem("Email", email, "DuplicateEmail".Localize()));
}
if (violations.Count > 0)
{
Expand Down Expand Up @@ -237,11 +238,11 @@ public virtual bool Validate(Kooboo.CMS.Membership.Models.Membership membership,
}
if (!membershipUser.IsApproved)
{
violations.Add(new DataViolationItem("UserName", userName, "The member still not actived."));
violations.Add(new DataViolationItem("UserName", userName, "The member still not actived.".Localize()));
}
if (membershipUser.IsLockedOut)
{
violations.Add(new DataViolationItem("UserName", userName, "The member was locked out."));
violations.Add(new DataViolationItem("UserName", userName, "The member was locked out.".Localize()));
}
if (violations.Count > 0)
{
Expand Down Expand Up @@ -275,11 +276,11 @@ public virtual bool Activate(Kooboo.CMS.Membership.Models.Membership membership,
List<DataViolationItem> violations = new List<DataViolationItem>();
if (membershipUser == null)
{
violations.Add(new DataViolationItem("UserName", userName, "The member does not exists."));
violations.Add(new DataViolationItem("UserName", userName, "The member does not exists.".Localize()));
}
if (string.IsNullOrEmpty(activateCode))
{
violations.Add(new DataViolationItem("ActivateCode", userName, "Activate code is null."));
violations.Add(new DataViolationItem("ActivateCode", userName, "Activate code is null.".Localize()));
}
if (membershipUser.IsApproved)
{
Expand Down Expand Up @@ -340,7 +341,7 @@ public virtual MembershipUser ForgotPassword(Kooboo.CMS.Membership.Models.Member
List<DataViolationItem> violations = new List<DataViolationItem>();
if (membershipUser == null)
{
violations.Add(new DataViolationItem("UserName", userName, "The member does not exists."));
violations.Add(new DataViolationItem("UserName", userName, "The member does not exists.".Localize()));
}
if (violations.Count > 0)
{
Expand All @@ -364,11 +365,11 @@ public virtual bool ResetPassword(Kooboo.CMS.Membership.Models.Membership member
List<DataViolationItem> violations = new List<DataViolationItem>();
if (membershipUser == null)
{
violations.Add(new DataViolationItem("UserName", userName, "The member does not exists."));
violations.Add(new DataViolationItem("UserName", userName, "The member does not exists.".Localize()));
}
if (string.IsNullOrEmpty(activateCode))
{
violations.Add(new DataViolationItem("ActivateCode", userName, "Activate code is null."));
violations.Add(new DataViolationItem("ActivateCode", userName, "Activate code is null.".Localize()));
}

var valid = !string.IsNullOrEmpty(membershipUser.ActivateCode) && membershipUser.ActivateCode == activateCode;
Expand All @@ -380,7 +381,7 @@ public virtual bool ResetPassword(Kooboo.CMS.Membership.Models.Membership member
}
else
{
violations.Add(new DataViolationItem("ActivateCode", userName, "Activate code is invalid."));
violations.Add(new DataViolationItem("ActivateCode", userName, "Activate code is invalid.".Localize()));
}
if (violations.Count > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Kooboo.CMS.Web.Authorizations;
using Kooboo.CMS.Web.Models;
using Kooboo.Drawing;
using Kooboo.Drawing.Filters;
using Kooboo.Globalization;
using Kooboo.IO;
using Kooboo.Web.Mvc;
Expand Down Expand Up @@ -690,6 +691,89 @@ public virtual ActionResult IsFileNameAvailable(string name, string folderName,
return Json(true, JsonRequestBehavior.AllowGet);
}
#endregion

#region Watermark

[Kooboo.CMS.Web.Authorizations.Authorization(AreaName = "Contents", Group = "", Name = "Content", Order = 1)]
[HttpPost]
public virtual ActionResult Watermark( string folderName, string[] docs )
{
var data = new JsonResultData(ModelState);
data.RunWithTry(( resultData ) =>
{
if( !string.IsNullOrWhiteSpace(folderName) && docs != null )
{
var folder = FolderManager.Get(Repository, folderName).AsActual();
var uuids = from uuid in docs where !string.IsNullOrEmpty(uuid) select uuid;
foreach( var uuid in uuids )
{
var content = folder.CreateQuery().WhereEquals("UUID", uuid).First();
var provider = Providers.DefaultProviderFactory.GetProvider<IMediaContentProvider>();
using( var sourceStream = new MemoryStream(provider.GetContentStream(content)) )
{
var imageFormat = GetImageFormat(Path.GetExtension(content.FileName));
if( imageFormat == null )
{
continue;
}
var stream = Watermark(Repository, sourceStream, imageFormat);
ContentManager.Update(Repository, folder, uuid, content.FileName, stream, User.Identity.Name);
}
}
}
resultData.ReloadPage = true;
});
return Json(data);
}

public static ImageFormat GetImageFormat( string extension )
{
switch( extension.ToLower() )
{
case ".jpg":
case ".jpeg":
return ImageFormat.Jpeg;
case ".gif":
return ImageFormat.Gif;
case ".png":
return ImageFormat.Png;
case ".bmp":
return ImageFormat.Bmp;
}
return null;
}
private Stream Watermark( Repository repository, Stream stream, ImageFormat imageFormat )
{
var waterImageFile = GetWaterImage(repository);
if (System.IO.File.Exists(waterImageFile))
{
var waterImage = Image.FromFile(waterImageFile);

var rawImage = Image.FromStream(stream);

var filter = new ImageWatermarkFilter
{
WaterMarkImage = waterImage,
Alpha = 0.7f,
Valign = WaterMarkFilter.VAlign.Right,
Halign = WaterMarkFilter.HAlign.Bottom
};
var image = filter.ExecuteFilter(rawImage);

var ms = new MemoryStream();
image.Save(ms, imageFormat);
ms.Seek(0, SeekOrigin.Begin);
return ms;
}
return stream;
}
private string GetWaterImage( Repository repository )
{
var path = new RepositoryPath(repository);

return Path.Combine(path.PhysicalPath, "Watermark.png");
}
#endregion
}

public class TextFileModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@
@("Export".Localize())
</a>
</li>
<li>
<a href="@Html.Raw(this.Url.Action("Watermark", ViewContext.RequestContext.AllRouteValues()))"
data-show-on-check="Any"
data-command-type="AjaxPost"
data-confirm="@("Are you sure you want to add watermark to these items?".Localize())">
@("Watermark".Localize())
</a>
</li>
</ul>
</li>
@foreach (var group in Kooboo.CMS.Sites.Extension.UI.TopToolbar.ToolbarButtons.GetToolbarButtons(ViewContext.RequestContext))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@
@("Export".Localize())
</a>
</li>
<li>
<a href="@Html.Raw(this.Url.Action("Watermark", ViewContext.RequestContext.AllRouteValues()))"
data-show-on-check="Any"
data-command-type="AjaxPost"
data-confirm="@("Are you sure you want to add watermark to these items?".Localize())">
@("Watermark".Localize())
</a>
</li>
</ul>
</li>
@foreach (var group in Kooboo.CMS.Sites.Extension.UI.TopToolbar.ToolbarButtons.GetToolbarButtons(ViewContext.RequestContext))
Expand Down
12 changes: 7 additions & 5 deletions Kooboo.CMS/Kooboo.CMS.Web/I18N/ru-RU.resx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Creation date: 2012/05/18
Version 1.0 for KooBoo CMS 3.2
This translation is made by Ella S. (http://kooboo-cms.ru/)

Microsoft ResX Schema
Microsoft ResX Schema

Version 2.0

Expand Down Expand Up @@ -2193,4 +2189,10 @@ Microsoft ResX Schema
<data name="Goto" xml:space="preserve">
<value>Перейти</value>
</data>
<data name="Are you sure you want to add watermark to these items?" xml:space="preserve">
<value>Вы действительно хотите добавить водяной знак на выбранные элементы?</value>
</data>
<data name="Watermark" xml:space="preserve">
<value>Водяной знак</value>
</data>
</root>
65 changes: 65 additions & 0 deletions Kooboo.CMS/Publish/Default/I18N/en-US.resx
Original file line number Diff line number Diff line change
@@ -1,5 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema

Version 2.0

The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.

Example:

... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>

There are any number of "resheader" rows that contain simple
name/value pairs.

Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.

The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:

Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.

mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
Expand Down Expand Up @@ -382,4 +441,10 @@
<data name="Save" xml:space="preserve">
<value>Save</value>
</data>
<data name="DuplicateEmail" xml:space="preserve">
<value>Email is already taken</value>
</data>
<data name="DuplicateUserName" xml:space="preserve">
<value>Username is already taken</value>
</data>
</root>
33 changes: 28 additions & 5 deletions Kooboo.CMS/Publish/Default/I18N/ru-RU.resx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Creation date: 2012/05/18
Version 1.0 for KooBoo CMS 3.2
This translation is made by Ella S. (http://kooboo-cms.ru/)

Microsoft ResX Schema
Microsoft ResX Schema

Version 2.0

Expand Down Expand Up @@ -2193,4 +2189,31 @@ Microsoft ResX Schema
<data name="Goto" xml:space="preserve">
<value>Перейти</value>
</data>
<data name="Activate code is invalid." xml:space="preserve">
<value>Неверный код активации.</value>
</data>
<data name="Activate code is null." xml:space="preserve">
<value>Не указан код активации.</value>
</data>
<data name="DuplicateEmail" xml:space="preserve">
<value>Данный email уже зарегистрирован в системе</value>
</data>
<data name="DuplicateUserName" xml:space="preserve">
<value>Данный логин занят</value>
</data>
<data name="The member does not exists." xml:space="preserve">
<value>Указанный пользователь не найден.</value>
</data>
<data name="The member still not actived." xml:space="preserve">
<value>Учетная запись не активированна</value>
</data>
<data name="The member was locked out." xml:space="preserve">
<value>Учетная запись заблокированна</value>
</data>
<data name="Are you sure you want to add watermark to these items?" xml:space="preserve">
<value>Вы действительно хотите добавить водяной знак на выбранные элементы?</value>
</data>
<data name="Watermark" xml:space="preserve">
<value>Водяной знак</value>
</data>
</root>