Esempio n. 1
0
		/// <summary>
		/// Deletes the member cookie from the browser 
		/// 
		/// Can be used in the public website
		/// </summary>
		/// <param Name="m">Member</param>
		public static void ClearMemberFromClient(Member m)
		{
			removeCookie("umbracoMemberId");
			removeCookie("umbracoMemberGuid");
			removeCookie("umbracoMemberLogin");

			RemoveMemberFromCache(m);
			HttpContext.Current.Trace.Write("member", "Member removed from client");
		}
Esempio n. 2
0
		/// <summary>
		/// Get the current member
		/// </summary>
		/// <returns>Returns the member, if visitor is not logged in: null</returns>
		public static Member GetCurrentMember()
		{
			try
			{
				int _currentMemberId = CurrentMemberId();
				if (_currentMemberId != 0)
				{
					// return member from cache
					Member m = GetMemberFromCache(_currentMemberId);
					if (m == null)
						m = new Member(_currentMemberId);

					if (m.UniqueId == new Guid(getCookieValue("umbracoMemberGuid")) &&
					    m.LoginName == getCookieValue("umbracoMemberLogin"))
						return m;

					return null;
				}
				else
					return null;
			}
			catch
			{
				return null;
			}
		}
Esempio n. 3
0
		/// <summary>
		/// Method is used when logging a member in.
		/// 
		/// Adds the member to the cache of logged in members
		/// 
		/// Uses cookie or session based recognition
		/// 
		/// Can be used in the runtime
		/// </summary>
		/// <param Name="m">The member to log in</param>
		/// <param Name="UseSession">Use sessionbased recognition</param>
		/// <param Name="TimespanForCookie">The live time of the cookie</param>
		public static void AddMemberToCache(Member m, bool UseSession, TimeSpan TimespanForCookie)
		{
			if (m != null)
			{
				Hashtable umbracoMembers = CachedMembers();

				// Check if member already exists
				if (umbracoMembers[m.Id] == null)
					umbracoMembers.Add(m.Id, m);

				if (!UseSession)
				{
					removeCookie("umbracoMemberId");

					// Add cookie with member-id
					addCookie("umbracoMemberId", m.Id.ToString(), TimespanForCookie);
					addCookie("umbracoMemberGuid", m.UniqueId.ToString(), TimespanForCookie);
					addCookie("umbracoMemberLogin", m.LoginName, TimespanForCookie);
				}
				else
				{
					HttpContext.Current.Session["umbracoMemberId"] = m.Id.ToString();
					HttpContext.Current.Session["umbracoMemberGuid"] = m.UniqueId.ToString();
					HttpContext.Current.Session["umbracoMemberLogin"] = m.LoginName;
				}

				// Debug information
				HttpContext.Current.Trace.Write("member",
				                                string.Format("Member added to cache: {0}/{1} ({2})",
				                                              m.Text, m.LoginName, m.Id));

				_memberCache["umbracoMembers"] = umbracoMembers;
			}
		}
Esempio n. 4
0
		/// <summary>
		/// Removes the member from the cache
		/// 
		/// Can be used in the public website
		/// </summary>
		/// <param Name="m">Member to remove</param>
		public static void RemoveMemberFromCache(Member m)
		{
			Hashtable umbracoMembers = CachedMembers();
			if (umbracoMembers.ContainsKey(m.Id))
				umbracoMembers.Remove(m.Id);

			_memberCache["umbracoMembers"] = umbracoMembers;
		}
Esempio n. 5
0
		/*
		public contentitem.ContentItem[] CreatedContent() {
			return new contentitem.ContentItem[0];
		}
		*/

		#region MemberHandle functions

		/// <summary>
		/// Method is used when logging a member in.
		/// 
		/// Adds the member to the cache of logged in members
		/// 
		/// Uses cookiebased recognition
		/// 
		/// Can be used in the runtime
		/// </summary>
		/// <param Name="m">The member to log in</param>
		public static void AddMemberToCache(Member m)
		{
			if (m != null)
			{
				// TODO: Hard coded
				Hashtable umbracoMembers = CachedMembers();

				// Check if member already exists
				if (umbracoMembers[m.Id] == null)
					umbracoMembers.Add(m.Id, m);

				removeCookie("umbracoMemberId");

				// Add cookie with member-id, guid and loginname
				addCookie("umbracoMemberId", m.Id.ToString(), 365);
				addCookie("umbracoMemberGuid", m.UniqueId.ToString(), 365);
				addCookie("umbracoMemberLogin", m.LoginName, 365);

				// Debug information
				HttpContext.Current.Trace.Write("member",
				                                "Member added to cache: " + m.Text + "/" + m.LoginName + " (" +
				                                m.Id + ")");

				_memberCache["umbracoMembers"] = umbracoMembers;
			}
		}
Esempio n. 6
0
		/// <summary>
		/// Deletes all members of the membertype specified
		/// 
		/// Used when a membertype is deleted
		/// 
		/// Use with care
		/// </summary>
		/// <param Name="dt">The membertype which are being deleted</param>
		public static void DeleteFromType(MemberType dt)
		{
			foreach (Content c in getContentOfContentType(dt))
			{
				// due to recursive structure document might already been deleted..
				if (IsNode(c.UniqueId))
				{
					Member tmp = new Member(c.UniqueId);
					tmp.delete();
				}
			}
		}
Esempio n. 7
0
		/// <summary>
		/// Creates a new member
		/// </summary>
		/// <param Name="Name">Membername</param>
		/// <param Name="mbt">Member type</param>
		/// <param Name="u">The Umbraco usercontext</param>
		/// <param Name="Email">The email of the user</param>
		/// <returns>The new member</returns>
		public static Member MakeNew(string Name, string Email, MemberType mbt, User u)
		{
			Guid newId = Guid.NewGuid();
			MakeNew(-1, _objectType, u.Id, 1, Name, newId);

			Member tmp = new Member(newId);

			tmp.CreateContent(mbt);
			// Create member specific data ..
			// TODO: SQL
			Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(_ConnString, CommandType.Text,
			                          "insert into cmsMember (nodeId,Email,LoginName,Password) values (@id,@email,@text,'')",
			                          new SqlParameter("@id", tmp.Id),
			                          new SqlParameter("@text", tmp.Text),
			                          new SqlParameter("@email", Email));
			return tmp;
		}
Esempio n. 8
0
		/// <summary>
		/// Retrieves a list of members by the first letter in their Name.
		/// </summary>
		/// <param Name="letter">The first letter</param>
		/// <returns></returns>
		public static Member[] getMemberFromFirstLetter(char letter)
		{
			// TODO: SQL
			string query =
				"Select id, text from umbracoNode where NodeObjectType = @objectType and text like @letter order by text";
			List<Member> m = new List<Member>();
			using (SqlDataReader dr = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteReader(_ConnString, CommandType.Text, query,
			                                                  new SqlParameter("@objectType", _objectType),
			                                                  new SqlParameter("@letter", letter + "%")))
			{
				while (dr.Read())
				{
					Member newMember = new Member(int.Parse(dr["id"].ToString()), true);
					newMember._text = dr["text"].ToString();
					m.Add(new Member(newMember.Id));
				}
			}
			return m.ToArray();
		}
Esempio n. 9
0
		/// <summary>
		/// Retrieves a list of members thats not start with a-z
		/// </summary>
		/// <returns>array of members</returns>
		public static Member[] getAllOtherMembers()
		{
			// TODO: SQL
			string query =
				"SELECT id, text FROM umbracoNode WHERE (nodeObjectType = @nodeObjectType) AND (ASCII(SUBSTRING(text, 1, 1)) NOT BETWEEN ASCII('a') AND ASCII('z')) AND (ASCII(SUBSTRING(text, 1, 1)) NOT BETWEEN ASCII('A') AND ASCII('Z'))";
			List<Member> m = new List<Member>();
			using (SqlDataReader dr = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteReader(_ConnString, CommandType.Text, query,
			                                                  new SqlParameter("@nodeObjectType", _objectType)))
			{
				while (dr.Read())
				{
					Member newMember = new Member(int.Parse(dr["id"].ToString()), true);
					newMember._text = dr["text"].ToString();
					m.Add(new Member(newMember.Id));
				}
			}

			return m.ToArray();
		}