Beispiel #1
0
        public Forum(int forumID)
        {
            umbraco.DataLayer.IRecordsReader dr = Data.SqlHelper.ExecuteReader("SELECT * FROM forumForums WHERE ID = @id", Data.SqlHelper.CreateParameter("@id", forumID));

            if (dr.Read()) {
                Node n = new Node(dr.GetInt("id"));

                    Forum f = new Forum();
                    Id = dr.GetInt("id");
                    Title = n.Name;

                    if(n.GetProperty("forumDescription") != null)
                        Description = n.GetProperty("forumDescription").Value;

                    Exists = true;
                    TotalComments = dr.GetInt("totalComments");
                    TotalTopics = dr.GetInt("totalTopics");

                    //Latest private vals
                    _latestAuthorID = dr.GetInt("latestAuthor");
                    _latestCommentID = dr.GetInt("latestComment");
                    _latestTopicID = dr.GetInt("latestTopic");
                    LatestPostDate = dr.GetDateTime("latestPostDate");

            } else
                Exists = false;

            dr.Close();
            dr.Dispose();
        }
Beispiel #2
0
 public static string GetMenuTitle(Node node)
 {
     if (node != null)
     {
         return node.GetPropertyValue("navigationTitle", node.Name);
     }
     return string.Empty;
 }
        protected void SendEmail(object sender, EventArgs e)
        {
            Node n = new Node(int.Parse(base.Request.QueryString["id"]));
            if (((n.NodeTypeAlias == "Event") && ((int.Parse(n.GetProperty("owner").Value) == this.m.Id) || (this.m.Id == 0x4ae))) && (this.MaxNumberOfEmails > this.EmailsSent(n)))
            {
                Event event2 = new Event(n.Id);
                List<Member> list = new List<Member>();
                string selectedValue = this.rbl_receivers.SelectedValue;
                if (selectedValue != null)
                {
                    if (!(selectedValue == "coming"))
                    {
                        if (selectedValue == "waiting")
                        {
                            list.AddRange(RelationToMember(EventRelation.GetPeopleWaiting(n.Id, event2.OnWaitingList)));
                        }
                        else if (selectedValue == "both")
                        {
                            list.AddRange(RelationToMember(EventRelation.GetPeopleSignedUpLast(n.Id, event2.SignedUp)));
                            list.AddRange(RelationToMember(EventRelation.GetPeopleWaiting(n.Id, event2.OnWaitingList)));
                        }
                    }
                    else
                    {
                        list.AddRange(RelationToMember(EventRelation.GetPeopleSignedUpLast(n.Id, event2.SignedUp)));
                    }
                }

                MailMessage message = new MailMessage();
                string str = "<p>\r\n You receive this email because you have signed up \r\n                                            for an event on the umbraco community site http://our.umbraco.org</p>\r\n\r\n                                            <p>You can view the event page \r\n                                            <a href='http://our.umbraco.org" + library.NiceUrl(n.Id) + "'>here</a></p>";
                message.Subject = this.tb_subject.Text;
                message.Body = this.tb_body.Text + str;
                message.From = new MailAddress("*****@*****.**", "Our Umbraco - Events");
                message.ReplyToList.Add(new MailAddress(this.m.Email));
                message.IsBodyHtml = true;
                foreach (Member member in list)
                {
                    try
                    {
                        message.Bcc.Add(new MailAddress(member.Email, member.Text));
                    }
                    catch
                    {
                    }
                }
                new SmtpClient().Send(message);
                Document document = Document.MakeNew(this.tb_subject.Text, DocumentType.GetByAlias("EventNews"), new User(0), n.Id);
                document.getProperty("bodyText").Value = this.tb_body.Text;
                document.getProperty("subject").Value = this.tb_subject.Text;
                document.getProperty("sender").Value = this.m.Id;
                document.Publish(new User(0));
                library.UpdateDocumentCache(document.Id);
                document.Save();
                base.Response.Redirect(n.NiceUrl);
            }
        }
Beispiel #4
0
 private static string safeProperty(umbraco.presentation.nodeFactory.Node n, string alias)
 {
     if (n.GetProperty(alias) != null && !string.IsNullOrEmpty(n.GetProperty(alias).Value))
     {
         return(n.GetProperty(alias).Value);
     }
     else
     {
         return(string.Empty);
     }
 }
 private void GetNodesOfType(Node parent, string NodeTypeAlias, List<Node> nodeList)
 {
     foreach (Node child in parent.Children)
     {
         GetNodesOfType(child, NodeTypeAlias, nodeList);
         if (string.IsNullOrEmpty(NodeTypeAlias) || child.NodeTypeAlias == NodeTypeAlias)
         {
             nodeList.Add(child);
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     library.RegisterJavaScriptFile("tinyMce", "/scripts/tiny_mce/tiny_mce_src.js");
     Node n = new Node(int.Parse(base.Request.QueryString["id"]));
     if ((n.NodeTypeAlias == "Event") && ((int.Parse(n.GetProperty("owner").Value) == this.m.Id) || (this.m.Id == 0x4ae)))
     {
         this.ph_holder.Visible = true;
         this.MaxNumberOfEmails -= this.EmailsSent(n);
         if (this.MaxNumberOfEmails <= 0)
         {
             this.bt_submit.Enabled = false;
         }
     }
 }
        public List<string> getpropertyitems(string PropertyName, int NodeId, string NodeTypeAlias, bool UseParent)
        {
            string cachekey = PRE_CACHE_KEY + PropertyName + "_" + NodeId.ToString() + "_" +NodeTypeAlias;
            if (HttpContext.Current.Cache[cachekey] != null)
            {
                return (List<string>)HttpContext.Current.Cache[cachekey];
            }
            else
            {
                List<string> propertyList = new List<string>();
                Node startNode;

                if (UseParent)
                {
                    startNode = new Node(NodeId).Parent;
                }
                else
                {
                    startNode = new Node(NodeId);
                }

                if (startNode != null)
                {
                    string nodeListCacheKey = PRE_CACHE_KEY + NodeId.ToString() + "_" +NodeTypeAlias;
                    List<Node> nodeList;
                    if (HttpContext.Current.Cache[nodeListCacheKey] != null)
                    {
                        nodeList = (List<Node>)HttpContext.Current.Cache[nodeListCacheKey];
                    }
                    else
                    {
                        nodeList = new List<Node>();
                        GetNodesOfType(startNode, NodeTypeAlias, nodeList);
                        HttpContext.Current.Cache.Add(nodeListCacheKey, nodeList, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 20, 0), CacheItemPriority.Normal, null);
                    }
                    foreach (Node n in nodeList)
                    {
                        if (n.GetProperty(PropertyName) != null)
                        {
                            propertyList.Add(n.GetProperty(PropertyName).Value);
                        }
                    }
                }
                propertyList.Sort();

                HttpContext.Current.Cache.Add(cachekey, propertyList.Distinct().ToList(), null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 20, 0), CacheItemPriority.Normal, null);

                return propertyList.Distinct().ToList();
            }
        }
Beispiel #8
0
 public static Node GetNode(int nodeId)
 {
     Node node = null;
     try
     {
         node = new Node(nodeId);
     }
     catch (Exception)
     {
         return null;
     }
     if (node.Id == 0)
     {
         return null;
     }
     return node;
 }
Beispiel #9
0
 public static string GetNodeUrl(Node node)
 {
     return GetNodeUrl(node, string.Empty);
 }
Beispiel #10
0
        private static Package convertToPackageFromNode(Node packageNode)
        {
            if (packageNode != null && packageNode.NodeTypeAlias == _projectAlias)
                {
                    Package retVal = new Package();

                    retVal.Text = packageNode.Name;
                    retVal.RepoGuid = new Guid(safeProperty(packageNode,"packageGuid"));
                    retVal.Description = safeProperty(packageNode,"description");
                    retVal.Protected = false;

                    retVal.Icon = "";
                    retVal.Thumbnail = safeProperty(packageNode, "defaultScreenshotPath");
                    retVal.Demo = "";

                    retVal.IsModule = false;
                    if (safeProperty(packageNode, "isModule") == "1")
                      retVal.IsModule = true;

                    if (umbraco.library.NiceUrl(packageNode.Id) != "")
                    {
                        retVal.Url = umbraco.library.NiceUrl(packageNode.Id);
                        retVal.Accepted = true;
                    }

                    retVal.HasUpgrade = false;

                    return retVal;
                }

            return null;
        }
Beispiel #11
0
        void Forum_AfterCreate(object sender, CreateEventArgs e)
        {
            //WB added to show these events are firing...
            umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, "Forum_AfterCreate in NotificationsWeb.EventHandlers.Forum() class is starting");

            //subscribe project owner to created forum
            uForum.Businesslogic.Forum f = (uForum.Businesslogic.Forum)sender;

            Node n = new Node(f.ParentId);
            if (n.NodeTypeAlias == "Project")
            {
                NotificationsWeb.BusinessLogic.Forum.Subscribe(
                    f.Id, Convert.ToInt32(n.GetProperty("owner").Value));
            }

            //WB added to show these events are firing...
            umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, "Forum_AfterCreate in NotificationsWeb.EventHandlers.Forum() class is finishing");
        }
Beispiel #12
0
 public static string GetNodeUrl(Node node, string alternateTemplate)
 {
     return GetNodeUrl(node, alternateTemplate, false);
 }
        public formResponse sendForm(formRequest request)
        {
            formResponse nr = new formResponse();
            nr.Result = "1";
            nr.Msg = string.Empty;

            try
            {
                // start Node Factory
                Node page = new Node(request.Id);

                string autoResponderId = page.GetProperty("emailField").Value;
                string autoResponderEmail = string.Empty;

                // construct the email message
                int rowCount = 0;
                string message = "<html><head></head><body><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"font-family: sans-serif; font-size: 13px; color: #222; border-collapse: collapse;\">";
                for (int i = 0; i < request.Values.Length; i++)
                {
                    string name = request.Names[i];
                    int index = request.FieldIds[i].LastIndexOf('_') + 1;
                    if (index > 0)
                    {
                        string fullId = request.FieldIds[i].Substring(index, request.FieldIds[i].Length - index);

                        if (fullId == autoResponderId)
                        {
                            autoResponderEmail = request.Values[i];
                        }

                        int id;
                        if (int.TryParse(fullId, out id))
                        {
                            Node node = new Node(id);
                            if (node != null)
                            {
                                if (node.GetProperty("label").Value.Length > 0)
                                {
                                    name = node.GetProperty("label").Value;
                                }
                                else if (node.NodeTypeAlias == "PliableText")
                                {
                                    if (node.GetProperty("defaultValue").Value.Length > 0)
                                    {
                                        name = node.GetProperty("defaultValue").Value;
                                    }
                                }
                            }
                        }
                    }
                    if (name.Length > 0)
                    {
                        rowCount++;
                        if (rowCount % 2 == 0)
                        {
                            message += string.Format("<tr><td style=\"background-color: #ffffff; padding: 4px 8px; vertical-align: top; width: 120px;\">{0}</td><td style=\"background-color: #ffffff; padding: 4px 8px; vertical-align: top;\">{1}</td></tr>", name, request.Values[i]);
                        }
                        else
                        {
                            message += string.Format("<tr><td style=\"background-color: #ebf5ff; padding: 4px 8px; vertical-align: top; width: 120px;\">{0}</td><td style=\"background-color: #ebf5ff; padding: 4px 8px; vertical-align: top;\">{1}</td></tr>", name, request.Values[i]);
                        }
                    }
                }
                message += "</table></body></html>";

                // determine the to address
                string emailTo = page.GetProperty("toAddress").Value;
                if (emailTo == null || emailTo.Length < 1)
                {
                    emailTo = ConfigurationManager.AppSettings.Get("PliableForm.defaultToAddress");
                    if (emailTo == null)
                    {
                        emailTo = umbraco.library.GetDictionaryItem("PliableForm.defaultToAddress");
                    }
                }
                string subject = page.GetProperty("emailSubject").Value;
                if (subject == null || subject.Length < 1)
                {
                    subject = ConfigurationManager.AppSettings.Get("PliableForm.defaultEmailSubject");
                    if (subject == null)
                    {
                        subject = umbraco.library.GetDictionaryItem("PliableForm.defaultEmailSubject");
                    }
                }

                req = request;
                MatchEvaluator reEval = new MatchEvaluator(this.replaceFields);

                // send the email
                SendEmailMessage(emailTo, message, Regex.Replace(subject, "{([^}]+)}", reEval), true);
                nr.Result = "2";

                // send the autoresponder email
                if (autoResponderEmail.Length > 4)
                {
                    string ARbody = page.GetProperty("autoResponderText").Value;
                    bool ARisHtml = false;
                    if (ARbody.Length < 1)
                    {
                        ARbody = page.GetProperty("autoResponderHtml").Value;
                        ARisHtml = true;
                    }

                    ARbody = Regex.Replace(ARbody, "{([^}]+)}", reEval);
                    SendEmailMessage(autoResponderEmail, ARbody, Regex.Replace(page.GetProperty("autoResponderSubject").Value, "{([^}]+)}", reEval), ARisHtml);
                }

            }
            catch (Exception ex)
            {
                nr.Result = "3";
                nr.Msg = ex.Message;
            }

            return nr;
        }
Beispiel #14
0
        public static string GetNodeUrl(Node node, string alternateTemplate, bool includeDomain)
        {
            // If node is null, just return an empty.String
            if (node == null)
            {
                return string.Empty;
            }

            // Check to see if the node is a redirect node.
            if (node.NodeTypeAlias == Configuration.ConfigurationManager.DocumentTypeAliases.Redirect.Value)
            {
                // Is it an internel link, then change node.
                int umbracoRedirectNodeId = node.GetPropertyValue("umbracoRedirect", -1);
                if (umbracoRedirectNodeId > -1)
                {
                    node = UmbracoUtil.GetNode(umbracoRedirectNodeId);
                    if (node == null)
                    {
                        return string.Empty;
                    }
                }
                else // check to see if we should do an external link
                {
                    string externalUrl = node.GetPropertyValue("externalLink", string.Empty);
                    if (externalUrl != string.Empty)
                    {
                        return externalUrl;
                    }
                }
            }

            bool umbracoUseDirectoryUrls = System.Configuration.ConfigurationManager.AppSettings["umbracoUseDirectoryUrls"] == "true";
            string url = string.Empty;

            string umbracoUrlAlias = node.GetPropertyValue("umbracoUrlAlias");
            if (umbracoUrlAlias != string.Empty && alternateTemplate == string.Empty)
            {
                if (umbracoUseDirectoryUrls == false && umbracoUrlAlias.EndsWith(".aspx") == false) // Running the site with .aspx extension
                {
                    url = "/" + umbracoUrlAlias + ".aspx";
                }
                else // Running the site with directory urls
                {
                    url = "/" + umbracoUrlAlias;
                }
            }
            else
            {
                int nodeLevel = node.Level();
                if (nodeLevel <= 2) // If we are on the frontpage of the site. (or below)
                {
                    url = "/";
                }
                else
                {
                    url = umbraco.library.NiceUrl(node.Id);
                    if (alternateTemplate != string.Empty)
                    {
                        if (umbracoUseDirectoryUrls) // Running the site with-out .aspx extension
                        {
                            url += "/" + alternateTemplate;
                        }
                        else // Running the site with directory urls
                        {
                            url = url.Replace(".aspx", "/" + alternateTemplate + ".aspx");
                        }
                    }
                }
            }

            if (includeDomain)
            {
                if (HttpContext.Current != null)
                {
                    if (HttpContext.Current.Request.ServerVariables["SERVER_NAME"] != null)
                    {
                        string domain = HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
                        string protocol = "http://";
                        if (HttpContext.Current.Request.ServerVariables["HTTPS"] != null && HttpContext.Current.Request.ServerVariables["HTTPS"] == "ON")
                        {
                            protocol = "https://";
                        }
                        url = string.Concat(protocol, domain, url);
                    }
                }
            }
            return url;
        }
Beispiel #15
0
 private int EmailsSent(Node n)
 {
     int num = 0;
     foreach (Node node in n.Children)
     {
         if (node.NodeTypeAlias == "EventNews")
         {
             num++;
         }
     }
     return num;
 }
Beispiel #16
0
 public NodeAxes(Node node)
 {
     this.node = node;
 }
Beispiel #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            umbraco.library.RegisterJavaScriptFile("tinyMce", "/scripts/tiny_mce/tiny_mce_src.js");

            //edit?
            if (Page.IsPostBack == false && string.IsNullOrEmpty(Request.QueryString["id"]) == false)
            {
                var node = new Node(int.Parse(Request.QueryString["id"]));
                //allowed?
                if (node.NodeTypeAlias == "Event" && int.Parse(node.GetProperty("owner").Value) == _member.Id)
                {
                    tb_name.Text = node.Name;
                    tb_desc.Text = node.GetProperty("description").Value;

                    tb_venue.Text = node.GetProperty("venue").Value;
                    tb_capacity.Text = node.GetProperty("capacity").Value;

                    tb_lat.Value = node.GetProperty("latitude").Value;
                    tb_lng.Value = node.GetProperty("longitude").Value;

                    dp_startdate.Text = DateTime.Parse(node.GetProperty("start").Value).ToString("MM/dd/yyyy H:mm");
                    dp_enddate.Text = DateTime.Parse(node.GetProperty("end").Value).ToString("MM/dd/yyyy H:mm");
                }
            }
        }
Beispiel #18
0
 public Message(Node node)
 {
     // TODO
 }
        protected void saveProject(object sender, CommandEventArgs e)
        {
            Member m = Member.GetCurrentMember();
            Document d;

            var memberHasEnoughReputation = MemberHasEnoughReputation(m);
            if (memberHasEnoughReputation == false)
            {
                holder.Visible = false;
                notallowed.Visible = true;
            }
            else
            {
                if (e.CommandName == "save")
                {

                    int pId = int.Parse(e.CommandArgument.ToString());

                    d = new Document(pId);

                    if ((int)d.getProperty("owner").Value == m.Id || Utils.IsProjectContributor(m.Id, d.Id))
                    {
                        d.Text = tb_name.Text;
                        d.getProperty("version").Value = tb_version.Text;
                        d.getProperty("description").Value = tb_desc.Text;

                        d.getProperty("stable").Value = cb_stable.Checked;
                        d.getProperty("status").Value = tb_status.Text;

                        d.getProperty("demoUrl").Value = tb_demoUrl.Text;
                        d.getProperty("sourceUrl").Value = tb_sourceUrl.Text;
                        d.getProperty("websiteUrl").Value = tb_websiteUrl.Text;

                        d.getProperty("vendorUrl").Value = tb_purchaseUrl.Text;

                        d.getProperty("licenseUrl").Value = tb_licenseUrl.Text;
                        d.getProperty("licenseName").Value = tb_license.Text;

                        d.getProperty("file").Value = dd_package.SelectedValue;
                        d.getProperty("defaultScreenshot").Value = dd_screenshot.SelectedValue;

                        if (dd_screenshot.SelectedIndex > -1)
                        {
                            d.getProperty("defaultScreenshotPath").Value =
                                new WikiFile(int.Parse(dd_screenshot.SelectedValue)).Path;
                        }
                        else
                        {
                            d.getProperty("defaultScreenshotPath").Value = "";
                        }

                        if (Request["projecttags[]"] != null)
                        {
                            CommunityController.SetTags(d.Id.ToString(), "project",
                                Request["projecttags[]"].ToString());
                        }

                        Node category = new Node(int.Parse(dd_category.SelectedValue));

                        //if we have a proper category, move the package
                        if (category != null && category.NodeTypeAlias == "ProductGroup") ;
                        {
                            if (d.Parent.Id != category.Id)
                            {
                                d.Move(category.Id);
                            }
                        }

                        if (d.getProperty("packageGuid") == null ||
                            string.IsNullOrEmpty(d.getProperty("packageGuid").Value.ToString()))
                            d.getProperty("packageGuid").Value = Guid.NewGuid().ToString();

                        d.Save();
                        d.Publish(new User(0));

                        library.UpdateDocumentCache(d.Id);
                        library.RefreshContent();
                    }

                }
                else
                {

                    d = Document.MakeNew(tb_name.Text, new DocumentType(TypeId), new User(0),
                        RootId);

                    d.getProperty("version").Value = tb_version.Text;
                    d.getProperty("description").Value = tb_desc.Text;

                    d.getProperty("stable").Value = cb_stable.Checked;

                    d.getProperty("demoUrl").Value = tb_demoUrl.Text;
                    d.getProperty("sourceUrl").Value = tb_sourceUrl.Text;
                    d.getProperty("websiteUrl").Value = tb_websiteUrl.Text;

                    d.getProperty("licenseUrl").Value = tb_licenseUrl.Text;
                    d.getProperty("licenseName").Value = tb_license.Text;

                    d.getProperty("vendorUrl").Value = tb_purchaseUrl.Text;

                    //d.getProperty("file").Value = dd_package.SelectedValue;
                    d.getProperty("owner").Value = m.Id;
                    d.getProperty("packageGuid").Value = Guid.NewGuid().ToString();

                    if (Request["projecttags[]"] != null)
                    {
                        CommunityController.SetTags(d.Id.ToString(), "project", Request["projecttags[]"].ToString());
                        d.getProperty("tags").Value = Request["projecttags[]"].ToString();
                    }

                    Node category = new Node(int.Parse(dd_category.SelectedValue));

                    //if we have a proper category, move the package
                    if (category != null && category.NodeTypeAlias == "ProductGroup") ;
                    {
                        if (d.Parent.Id != category.Id)
                        {
                            d.Move(category.Id);
                        }
                    }

                    d.Save();

                    d.Publish(new User(0));
                    library.UpdateDocumentCache(d.Id);

                    library.RefreshContent();
                }
                Response.Redirect(library.NiceUrl(GotoOnSave));
            }
        }
Beispiel #20
0
        internal static WikiFile PackageFileByGuid(Guid pack)
        {
            XPathNodeIterator xpn = umbraco.library.GetXmlNodeByXPath("descendant::* [@isDoc and translate(packageGuid,'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = translate('" + pack.ToString() + "','ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')]");

            if (xpn.MoveNext())
            {
                if (xpn.Current is IHasXmlNode)
                {
                    Node node = new Node(((IHasXmlNode)xpn.Current).GetNode());
                    string fileId = safeProperty(node, "file");
                    int _id;

                    if (int.TryParse(fileId, out _id))
                    {
                        string cookieName = "ProjectFileDownload" + fileId;

                        //we clear the cookie on the server just to be sure the download is accounted for
                        if (HttpContext.Current.Request.Cookies[cookieName] != null)
                        {
                            HttpCookie myCookie = new HttpCookie(cookieName);
                            myCookie.Expires = DateTime.Now.AddDays(-1d);
                            HttpContext.Current.Response.Cookies.Add(myCookie);
                        }

                        WikiFile wf = new WikiFile(_id);
                        wf.UpdateDownloadCounter(true,true);

                        return wf;
                    }
                }
            }

            return null;
        }
Beispiel #21
0
        public static List<Forum> Forums(int parentId)
        {
            List<Forum> lt = new List<Forum>();

            umbraco.DataLayer.IRecordsReader dr;

            if (parentId > 0) {
                dr = Data.SqlHelper.ExecuteReader(
                    "SELECT * FROM forumForums WHERE parentID = @parentId ORDER by sortOrder ASC", Data.SqlHelper.CreateParameter("@parentId", parentId)
                );
            } else {
                dr = Data.SqlHelper.ExecuteReader(
                    "SELECT * FROM forumForums ORDER by sortOrder ASC"
                );
            }

            while (dr.Read()) {
                try {
                    Node n = new Node(dr.GetInt("id"));

                    if (n != null)
                    {
                        Forum f = new Forum();

                        f.Id = dr.GetInt("id");
                        f.ParentId = dr.GetInt("parentId");
                        f.Title = n.Name;

                        if(n.GetProperty("forumDescription") != null)
                            f.Description = n.GetProperty("forumDescription").Value;

                        f.Exists = true;
                        f.SortOrder = dr.GetInt("SortOrder");

                        //Latest private vals
                        f._latestAuthorID = dr.GetInt("latestAuthor");
                        f._latestCommentID = dr.GetInt("latestComment");
                        f._latestTopicID = dr.GetInt("latestTopic");

                        f.LatestPostDate = dr.GetDateTime("latestPostDate");
                        f.TotalComments = dr.GetInt("totalComments");
                        f.TotalTopics = dr.GetInt("totalTopics");

                        lt.Add(f);
                    }
                } catch(Exception ex) {
                    Log.Add(LogTypes.Debug, -1, ex.ToString());
                }
            }
            dr.Close();
            dr.Dispose();

            return lt;
        }
Beispiel #22
0
        private static Category convertToCategoryFromNode(Node categoryNode, bool includePackages)
        {
            if (categoryNode != null && categoryNode.NodeTypeAlias == _projectGroupAlias)
                {
                    Category retVal = new Category();

                    retVal.Text = categoryNode.Name;
                    retVal.Id = categoryNode.Id;
                    retVal.Description = safeProperty(categoryNode,"description");
                    retVal.Url = umbraco.library.NiceUrl(categoryNode.Id);

                    if(includePackages){
                        foreach(Node p in categoryNode.Children){
                            Package pack = convertToPackageFromNode(p);
                            if(pack != null)
                                retVal.Packages.Add(pack);
                        }
                    }

                    return retVal;
                }

            return null;
        }
        /// <summary>
        /// Moves a Post if the Post Date Changes
        /// </summary>
        /// <param name="sender">Document Being Published</param>
        /// <param name="e">Publish Event Args</param>
        void Document_BeforePublish(Document sender, umbraco.cms.businesslogic.PublishEventArgs e)
        {
            if (sender.ContentType.Alias == "BlogPost") //As this runs for every publish event, only proceed if this is BlogPost
            {
                Log.Add(LogTypes.Debug, sender.User, sender.Id, string.Format("Start Before Publish Event for Blog Post {0}", sender.Id));
                if (sender.getProperty("PostDate") != null) //If no post date, skip 
                {
                    if (sender.Parent != null)  //If top of tree, something is wrong.  Skip.
                    {
                        try
                        {
                            DocumentVersionList[] postVersions = sender.GetVersions();
                            bool _versionCheck = true;
                            DateTime postDate;
                            postDate = System.Convert.ToDateTime(sender.getProperty("PostDate").Value);
                            if (postVersions.Length > 1)  //If it has been published, check post date info
                            {
                                //Length -1 is current version Length -2 is past version (if it exists)
                                Guid previousVersion = postVersions[postVersions.Length - 2].Version;
                                Document doc = new Document(sender.Id, previousVersion);
                                DateTime previousPostDate = System.Convert.ToDateTime(doc.getProperty("PostDate").Value);

                                _versionCheck = (postDate != previousPostDate);
                            }

                            if (_versionCheck)  //Only do the date folder movement if the PostDate is changed or is new Post.
                            {
                                string[] strArray = { postDate.Year.ToString(), postDate.Month.ToString(), postDate.Day.ToString() };
                                if (strArray.Length == 3)
                                {
                                    Node topBlogLevel = new Node(sender.Parent.Id);
                                    //Traverse up the tree to Find the Blog Node since we are likely in a Date Folder path
                                    while (topBlogLevel != null && topBlogLevel.NodeTypeAlias != "Blog")
                                    {
                                        if (topBlogLevel.Parent != null)
                                        {
                                            topBlogLevel = new Node(topBlogLevel.Parent.Id);
                                        }
                                        else
                                        {
                                            topBlogLevel = null;
                                        }
                                    }
                                    if (topBlogLevel != null)
                                    {
                                        Document document = null;
                                        Node folderNode = null;
                                        foreach (Node ni in topBlogLevel.Children)
                                        {
                                            if (ni.Name == strArray[0])
                                            {
                                                folderNode = new Node(ni.Id);
                                                document = new Document(ni.Id);
                                                break;
                                            }
                                        }
                                        if (folderNode == null)
                                        {
                                            document = Document.MakeNew(strArray[0], DocumentType.GetByAlias("DateFolder"), sender.User, topBlogLevel.Id);
                                            document.Publish(sender.User);
                                            library.UpdateDocumentCache(document.Id);
                                            folderNode = new Node(document.Id);
                                        }
                                        Node folderNode2 = null;
                                        foreach (Node ni in folderNode.Children)
                                        {
                                            if (ni.Name == strArray[1])
                                            {
                                                folderNode2 = new Node(ni.Id);
                                                break;
                                            }
                                        }
                                        if (folderNode2 == null)
                                        {
                                            Document document2 = Document.MakeNew(strArray[1], DocumentType.GetByAlias("DateFolder"), sender.User, folderNode.Id);
                                            document2.Publish(sender.User);
                                            library.UpdateDocumentCache(document2.Id);
                                            folderNode2 = new Node(document2.Id);
                                        }
                                        Document document3 = null;  //As this is the last check, a document object is fine
                                        foreach (Node ni in folderNode2.Children)
                                        {
                                            if (ni.Name == strArray[2])
                                            {
                                                document3 = new Document(ni.Id);
                                                break;
                                            }
                                        }
                                        if (document3 == null)
                                        {
                                            document3 = Document.MakeNew(strArray[2], DocumentType.GetByAlias("DateFolder"), sender.User, folderNode2.Id);
                                            document3.Publish(sender.User);
                                            library.UpdateDocumentCache(document3.Id);
                                        }
                                        if (sender.Parent.Id != document3.Id)
                                        {
                                            sender.Move(document3.Id);
                                            Log.Add(LogTypes.Debug, sender.User, sender.Id, string.Format("Move Required for BlogPost {0} for PostDate {1}.  Moved Under Node {2}", sender.Id, postDate.ToShortDateString(), document3.Id));
                                        }
                                    }
                                    else
                                    {
                                        Log.Add(LogTypes.Debug, sender.User, sender.Id, string.Format("Unable to determine top of Blog for BlogPost {0} while attempting to move to new Post Date", sender.Id));
                                    }

                                }
                            }
                        }
                        catch (Exception Exp)
                        {
                            Log.Add(LogTypes.Debug, sender.User, sender.Id, string.Format("Error while Finding Blog Folders for BlogPost {0} while trying to move to new Post Date.  Error: {1}", sender.Id, Exp.Message));
                        }

                        umbraco.library.RefreshContent();
                    }
                }
            }
        }
Beispiel #24
0
 public static string GetCategoryName(this IListingItem project)
 {
     var node = new Node(project.Id);
     return node.Parent.Name;
 }