adds access by circle to blog posts

This commit is contained in:
Paul Schneider 2015-07-02 14:42:18 +02:00
commit f25aa8ff97
32 changed files with 465 additions and 274 deletions

View file

@ -2,6 +2,8 @@ using System;
using System.Configuration;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Yavsc.Model.Circles;
using System.Web.Mvc;
namespace Yavsc.Model.Blogs
{
@ -121,11 +123,21 @@ namespace Yavsc.Model.Blogs
/// <value><c>true</c> if visible; otherwise, <c>false</c>.</value>
public bool Visible { get; set ; }
/// <summary>
/// Gets or sets the circles allowed to read this ticket.
/// An empty collection specifies a public post.
/// </summary>
/// <value>The circles.</value>
[Display(Name="Cercles autorisés")]
public long[] AllowedCircles { get; set; }
/// <summary>
/// Gets or sets the tags.
/// </summary>
/// <value>The tags.</value>
public string [] Tags { get; set ; }
}
}

View file

@ -3,6 +3,8 @@ using Yavsc.Model.Blogs;
using Yavsc.Model.RolesAndMembers;
using System.Web;
using System.Web.Security;
using Yavsc.Model.Circles;
using System.Web.Mvc;
namespace Yavsc.Model.Blogs
@ -17,10 +19,11 @@ namespace Yavsc.Model.Blogs
/// </summary>
/// <returns>The comment.</returns>
/// <param name="cmtid">Cmtid.</param>
public static long RemoveComment(long cmtid)
public static long RemoveComment (long cmtid)
{
return Provider.RemoveComment (cmtid);
}
/// <summary>
/// Comment the specified from, postid, content and visible.
/// </summary>
@ -42,7 +45,7 @@ namespace Yavsc.Model.Blogs
public static BlogProvider Provider {
get {
if (provider == null)
provider = BlogHelper.GetProvider();
provider = BlogHelper.GetProvider ();
return provider;
}
}
@ -55,7 +58,7 @@ namespace Yavsc.Model.Blogs
/// <param name="title">Title.</param>
public static BlogEntry GetPost (string username, string title)
{
return Provider.GetPost (username, title );
return Provider.GetPost (username, title);
}
/// <summary>
@ -63,7 +66,7 @@ namespace Yavsc.Model.Blogs
/// </summary>
/// <returns>The post.</returns>
/// <param name="postid">Postid.</param>
public static BlogEntry GetPost(long postid)
public static BlogEntry GetPost (long postid)
{
return Provider.GetPost (postid);
}
@ -75,9 +78,10 @@ namespace Yavsc.Model.Blogs
/// <param name="title">Title.</param>
/// <param name="content">Content.</param>
/// <param name="visible">If set to <c>true</c> visible.</param>
public static void Post(string username, string title, string content, bool visible)
/// <param name="cids">sets the circles.</param>
public static long Post (string username, string title, string content, bool visible, long [] cids)
{
Provider.Post(username, title, content, visible );
return Provider.Post (username, title, content, visible, cids);
}
/// <summary>
@ -87,9 +91,10 @@ namespace Yavsc.Model.Blogs
/// <param name="title">Title.</param>
/// <param name="content">Content.</param>
/// <param name="visible">If set to <c>true</c> visible.</param>
public static void UpdatePost(long postid, string title, string content, bool visible)
/// <param name="cids">sets the circles.</param>
public static void UpdatePost (long postid, string title, string content, bool visible,long [] cids)
{
Provider.UpdatePost(postid, title, content, visible);
Provider.UpdatePost (postid, title, content, visible,cids);
}
/// <summary>
@ -101,10 +106,11 @@ namespace Yavsc.Model.Blogs
/// <param name="pageIndex">Page index.</param>
/// <param name="pageSize">Page size.</param>
/// <param name="totalRecords">Total records.</param>
public static BlogEntryCollection FindPost (string pattern, FindBlogEntryFlags searchflags, int pageIndex, int pageSize, out int totalRecords)
public static BlogEntryCollection FindPost (string readersName, string pattern, FindBlogEntryFlags searchflags, int pageIndex, int pageSize, out int totalRecords)
{
return Provider.FindPost (pattern, searchflags, pageIndex, pageSize, out totalRecords);
return Provider.FindPost (readersName, pattern, searchflags, pageIndex, pageSize, out totalRecords);
}
/// <summary>
/// Removes the post.
/// </summary>
@ -118,7 +124,7 @@ namespace Yavsc.Model.Blogs
throw new AccessViolationException (
string.Format (
"{1}, Vous n'avez pas le droit de suprimer des billets du Blog de {0}",
username,rguser));
username, rguser));
}
}
Provider.RemovePost (username, title);
@ -142,17 +148,19 @@ namespace Yavsc.Model.Blogs
/// <returns>The comments.</returns>
/// <param name="postid">Postid.</param>
/// <param name="getHidden">If set to <c>true</c> get hidden.</param>
public static Comment[] GetComments(long postid, bool getHidden=true)
public static Comment[] GetComments (long postid, bool getHidden = true)
{
return Provider.GetComments (postid,getHidden);
return Provider.GetComments (postid, getHidden);
}
/// <summary>
/// Tag the specified post by postid.
/// </summary>
/// <param name="postid">Postid.</param>
/// <param name="tag">Tag.</param>
/// <returns>The tag identifier</returns>
public static long Tag(long postid, string tag) {
public static long Tag (long postid, string tag)
{
return Provider.Tag (postid, tag);
}

View file

@ -2,6 +2,8 @@ using System;
using System.Configuration;
using System.Configuration.Provider;
using System.Collections.Generic;
using Yavsc.Model.Circles;
using System.Web.Mvc;
namespace Yavsc.Model.Blogs
{
@ -25,14 +27,6 @@ namespace Yavsc.Model.Blogs
/// <param name="title">Title.</param>
public abstract BlogEntry GetPost (string username, string title);
/// <summary>
/// Gets the post identifier.
/// </summary>
/// <returns>The post identifier.</returns>
/// <param name="username">Username.</param>
/// <param name="title">Title.</param>
public abstract long GetPostId (string username, string title);
/// <summary>
/// Post the specified username, title, content and visible.
/// </summary>
@ -40,7 +34,7 @@ namespace Yavsc.Model.Blogs
/// <param name="title">Title.</param>
/// <param name="content">Content.</param>
/// <param name="visible">If set to <c>true</c> visible.</param>
public abstract long Post (string username, string title, string content, bool visible);
public abstract long Post (string username, string title, string content, bool visible, long[] allowedCircles);
/// <summary>
/// Updates the post.
@ -49,7 +43,7 @@ namespace Yavsc.Model.Blogs
/// <param name="title">Title.</param>
/// <param name="content">Content.</param>
/// <param name="visible">If set to <c>true</c> visible.</param>
public abstract void UpdatePost (long postid, string title, string content, bool visible);
public abstract void UpdatePost (long postid, string title, string content, bool visible, long[] allowedCircles);
/// <summary>
/// Finds the post.
@ -60,7 +54,7 @@ namespace Yavsc.Model.Blogs
/// <param name="pageIndex">Page index.</param>
/// <param name="pageSize">Page size.</param>
/// <param name="totalRecords">Total records.</param>
public abstract BlogEntryCollection FindPost (string pattern, FindBlogEntryFlags searchflags,
public abstract BlogEntryCollection FindPost (string readersName, string pattern, FindBlogEntryFlags searchflags,
int pageIndex, int pageSize, out int totalRecords);
/// <summary>

View file

@ -1,3 +1,14 @@
2015-07-02 Paul Schneider <paul@pschneider.fr>
* ListItem.cs:
* YavscModel.csproj:
* BlogEntry.cs:
* BlogManager.cs:
* BlogProvider.cs:
* CircleManager.cs:
* CircleProvider.cs:
* SimpleMessage.cs:
2015-06-26 Paul Schneider <paul@pschneider.fr>
* Period.cs:

View file

@ -73,47 +73,8 @@ namespace Yavsc.Model.Circles
defaultProvider = ci.Invoke (Type.EmptyTypes) as CircleProvider;
defaultProvider.Initialize (pSection.DefaultProvider,pSetDef.Parameters);
}
/*
foreach (ProviderSettings pSettings in
providerSettings)
{
Console.WriteLine(
"Provider settings name: {0}",
pSettings.Name);
Console.WriteLine(
"Provider settings type: {0}",
pSettings.Type);
NameValueCollection parameters =
pSettings.Parameters;
IEnumerator pEnum =
parameters.GetEnumerator();
int i = 0;
while (pEnum.MoveNext())
{
string pLength =
parameters[i].Length.ToString();
Console.WriteLine(
"Provider ssettings: {0} has {1} parameters",
pSettings.Name, pLength);
}
}
*/
}
}
}

View file

@ -25,6 +25,8 @@ using System.Collections.Specialized;
using System.Collections;
using System.Reflection;
using System.Configuration.Provider;
using System.Web.Mvc;
using System.Collections.Generic;
namespace Yavsc.Model.Circles
{
@ -70,7 +72,14 @@ namespace Yavsc.Model.Circles
/// <summary>
/// List this instance.
/// </summary>
public abstract CircleInfoCollection List(string user);
public abstract IEnumerable<ListItem> List(string user);
/// <summary>
/// Covers the specified username.
/// </summary>
/// <param name="circle_ids">circle's owner.</param>
/// <param name="member">Username in his circle.</param>
public abstract bool Matches(long [] circle_ids, string member);
}

View file

@ -1,5 +1,5 @@
//
// CircleInfoCollection.cs
//
// ListItem.cs
//
// Author:
// Paul Schneider <paul@pschneider.fr>
@ -18,18 +18,15 @@
//
// 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;
namespace Yavsc.Model.Circles
namespace Yavsc.Model
{
/// <summary>
/// Circle info collection.
/// </summary>
public class CircleInfoCollection : List<CircleInfo>
public class ListItem
{
public string Value { get; set; }
public string Text { get; set; }
public string Icon { get; set; }
}
}

View file

@ -1,5 +1,5 @@
//
// CircleInfo.cs
//
// Message.cs
//
// Author:
// Paul Schneider <paul@pschneider.fr>
@ -18,31 +18,35 @@
//
// 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.ComponentModel.DataAnnotations;
namespace Yavsc.Model.Circles
namespace Yavsc.Model.Messaging
{
/// <summary>
/// Circle info.
/// Simple message.
/// </summary>
public class CircleInfo
public class SimpleMessage
{
public long Id { get; set; }
public string Title { get; set; }
public CircleInfo(Circle c)
{
Id = c.Id;
Title = c.Title;
}
public CircleInfo(long id, string title)
{
Id = id;
Title = title;
}
/// <summary>
/// Gets or sets the user name this message is comming from.
/// </summary>
/// <value>From.</value>
public string From { get; set; }
/// <summary>
/// Gets or sets the user names, separted by semilicon to which this message will be sent.
/// </summary>
/// <value>To.</value>
public string To { get; set; }
/// <summary>
/// Gets or sets the subject.
/// </summary>
/// <value>The subject.</value>
public string Subject { get; set; }
/// <summary>
/// Gets or sets the body.
/// </summary>
/// <value>The body.</value>
public string Body { get; set; }
}
}

View file

@ -143,8 +143,6 @@
<Compile Include="Calendar\YaEvent.cs" />
<Compile Include="Google\GCMRegisterModel.cs" />
<Compile Include="Circles\Circle.cs" />
<Compile Include="Circles\CircleInfo.cs" />
<Compile Include="Circles\CircleInfoCollection.cs" />
<Compile Include="Circles\CircleManager.cs" />
<Compile Include="Circles\CircleProvider.cs" />
<Compile Include="DataProviderConfigurationSection.cs" />
@ -160,6 +158,8 @@
<Compile Include="RolesAndMembers\ProviderPublicInfo.cs" />
<Compile Include="RolesAndMembers\GCMRegister.cs" />
<Compile Include="RolesAndMembers\LostPasswordModel.cs" />
<Compile Include="Messaging\SimpleMessage.cs" />
<Compile Include="ListItem.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
@ -174,6 +174,7 @@
<Folder Include="Google\Messaging\" />
<Folder Include="Circles\" />
<Folder Include="RolesAndMembers\" />
<Folder Include="Messaging\" />
</ItemGroup>
<ProjectExtensions>
<MonoDevelop>