dnnsoftware / Dnn.Platform

DNN (formerly DotNetNuke) is the leading open source web content management platform (CMS) in the Microsoft ecosystem.
https://dnncommunity.org/
MIT License
1.03k stars 752 forks source link

Journal: A post created in Social Groups will not create a back link and store ItemData Url & Title. #3035

Closed thabaum closed 2 years ago

thabaum commented 5 years ago

Description of bug

A post on a community wall needs to have an identity so visitors can connect to the message being posted more than just reading the text.

Steps to reproduce

List the steps to reproduce the behavior:

  1. Go to a social group and make a post
  2. Go to an activity feed for the website and it shows up without a link to the social group to identify where it came from or what it is in relation to.

Current result

No back link going to the place of origin if it is from a social group.

Expected result

A link to the social group activity page.

Screenshots

If applicable, provide screenshots to help explain your problem.

Error log

Paste the error log that is related to this issue.

Additional context

It would be great to be able to set default permissions for group views so that the group creator would be the moderator that can set the privacy for the group and private group messages are not posted to the world but everyone can see them in the group. Group view permissions override the user view permissions. It would be nice to have a few lite features like this to manage groups and an easy way to extend group module features from that first nice example.

Affected version

Affected browser

stale[bot] commented 4 years ago

We have detected this issue has not had any activity during the last 90 days. That could mean this issue is no longer relevant and/or nobody has found the necessary time to address the issue. We are trying to keep the list of open issues limited to those issues that are relevant to the majority and to close the ones that have become 'stale' (inactive). If no further activity is detected within the next 14 days, the issue will be closed automatically. If new comments are are posted and/or a solution (pull request) is submitted for review that references this issue, the issue will not be closed. Closed issues can be reopened at any time in the future. Please remember those participating in this open source project are volunteers trying to help others and creating a better DNN Platform for all. Thank you for your continued involvement and contributions!

thabaum commented 4 years ago

I am still digging into all the journal files see how I can improve things such as this issue. I went stale a few weeks but this issue and other with the journal data items for 'link' types is currently not saving the http url to the journal. #3308

I have read the entire module code a few times so it will start to flow in my mind hopefully soon.

thabaum commented 4 years ago

still on my back burner but if someone else dives in please be my guest ;) I will be making another go of things in the next couple weeks see what I can get done to help here and on a few other things related to this area. Thank you.

thabaum commented 4 years ago

Maybe two weeks I can take a look at this along with the other journal issues. I will be looking for DNN Docs to give me some love on the topic :)

stale[bot] commented 3 years ago

We have detected this issue has not had any activity during the last 90 days. That could mean this issue is no longer relevant and/or nobody has found the necessary time to address the issue. We are trying to keep the list of open issues limited to those issues that are relevant to the majority and to close the ones that have become 'stale' (inactive). If no further activity is detected within the next 14 days, the issue will be closed automatically. If new comments are are posted and/or a solution (pull request) is submitted for review that references this issue, the issue will not be closed. Closed issues can be reopened at any time in the future. Please remember those participating in this open source project are volunteers trying to help others and creating a better DNN Platform for all. Thank you for your continued involvement and contributions!

stale[bot] commented 3 years ago

This issue has been closed automatically due to inactivity (as mentioned 14 days ago). Feel free to re-open the issue if you believe it is still relevant.

thabaum commented 2 years ago

Coming alive! My next upcoming challenge after https://github.com/dnnsoftware/Dnn.Platform/issues/2314 and https://github.com/dnnsoftware/Dnn.Platform/issues/3308 are fixed.

thabaum commented 2 years ago

OK, for a recap here.

Visit a social group and post something inside the social group's page "journal module" no back link info is created for the activity feed page. The challenge is...

I am going to test this functionality out now.

note: autoconfigure site creates the navigation links for social groups at the bottom of a default DNN template skin. This should be above members or activities sections below the social group name by default.

image

To what is on topic:

  1. This is expected when inside a group:

image

  1. This is where the back link to the group journal module social page is expected: image

  2. Notice: Back links to the groups created are added to those journal activity posts.

  3. Here is how DNN Forums handles it by using the title and making the link for when someone discusses something.

image

  1. This is how the blog performs this task: image

  2. My question is if to create a link with the social group name for text after the name but prior to the message or at the end of the message? Or should I create a Display Name posted in Group Name after the user link made and put the message on the next line under it with a language file for the "posted in" section.

Some examples of what my question is concerning to move forward include the following:

Oh boy another issue with social group posts or comments not being displayed on profile. image

The first address used should be made a link. I would not mind having a gallery approach to multiple links as well but that is little too dreamy right now. You never know v10 might pull it off. This also helps a user understand the first link in a post gets activated, and only the first. image

I swapped the template out for the post I created "Cool group created!" which was from inside the groups journal to the same as used with when creating a group and also put a title of the group and itemData database information. The words in the template would need to be changed of course to in laymen's terms NAME shared in the group TITLE

The example of using the group created template with the group shared post is below. This was the result: image

To suppress this as a solution we could use 2 more templates inserted into the SharedResources.resx file that share one journal type that is for shared posts created each inside and out of a page containing the social group's DNN Platform module app. Have a switch that happens in the view state depending on if it is being displayed on a page with or without a social group's module installed on it.

I am collecting notes here as I go through this process. Please bear with me as I try to make this recap make some sense for when I come back to visit it potentially days down the road. I am hoping to get some quality feedback so I can make us a PR to be reviewed by the project maintainers.

My next step is creating these templates. Looking at the resx file in the project I will need to create journal_groupshare.Text and the default share post message have switch using a single unique JournalId letting the DNN Platform know it has two templates and depending on if there is a social group module or not on the page the app will use one template or the other.

thabaum commented 2 years ago

I would love some feedback on talking point number 5, oh wait now its 6, if anyone has a minute. I like to do things only once if possible and I have to do it 👍 . I will dig around this tonight start testing things tomorrow if not sooner. This will be a fun one if I can pull it off however if anyone wants to just whip this out laughing at me trying please be my guest! I have been wanting to enhance these mods for a while so they make sense working together with the DNN Platform out the box as expected.

Thanks again in advance, love the help and support from anyone when I get it! I really think @Tychodewaard and few others should be putting down some feelings here if you have a minute to what you think would be the best long term solution even if just agreeing with a solution put a thumbs up when you can. I will give this a few days to collaborate. Cheers!

thabaum commented 2 years ago

P.S. can I have this re-opened? Thank you!

valadas commented 2 years ago

Issue reopened @thabaum I am afraid I can't be of much help on the Journal as I did not use it much, but will be glad to review PRs about it.

Tychodewaard commented 2 years ago

@Timo-Breumelhof Tomorrow a quick call to discuss this?

Timo-Breumelhof commented 2 years ago

@Tychodewaard sure

Timo-Breumelhof commented 2 years ago

@thabaum I had a look at the issue and I agree it's an issue. Responding to point 5, I would prefer:

User Display Name posted in: Group Name Link Message

What if you would use static localization for this message (with tokens)?

[User:DisplayName] posted in: <a href="[GroupLink]">[Groupname]</a>

That way one can change the message as needed..

Tychodewaard commented 2 years ago

@thabaum Adding 2cents to what @Timo-Breumelhof said: it would be nice if we can see :

thabaum commented 2 years ago

Thank you @Timo-Breumelhof and @Tychodewaard for your much appreciated feedback. I agree what is said and will follow these suggestions as I can.

I like the idea of displaying the group title and forum category. After reviewing your suggestions @Tychodewaard I would probably like to do it something like the following: image

There is an added challenge now as I would need to possibly make a group item in the itemData field in the database and logic to hold the extra information of a two more Urls and Title's AND edit the DNN forum and DNN Blog projects to pass this information of a as well as all modules that want to display this information would need to add the ability.

This would be better to put into another PR down the road as it is a little more complex to implement. With work currently with what is readily available in DNN to remove any confusion while using the system just shooting for @Timo-Breumelhof suggestion will suffice for now. The backlink to the messages in the forum is at least being created. A social group journal post does not get a back link.

I am trying currently to see if I can put the logic into a resx file without breaking things and having it work. @valadas @bdukes maybe can help me answer this. I just really need a syntax example of how an if (){} statement would look inside a resx file for this module. The variables I am after is GroupID from the page if it has one... dont show the group post backlink. Seems simple enough to solve the that part of this upcoming solution.

Then I just need to also add to the logic for when a post is made inside a group to also add the itemData such as url,title,summary...

If I make any adjustments to adding new urls to the resx templates I will add/test solutions on the DNN Blog, DNN Forums and DNN Events modules to share the same information. So that would be a multi-PR mission.

I will possibly also migrate one of these modules to the next generation if I can find the time to learn about and do it.

If any of the current templates for posts going into journal need adjusted, I will be happy to do this as well to keep things looking uniform default.

Keep the ideas rolling here, but I need to stick to the main purpose of this PR unless it is something broken. I think if you are using the social modules, so am I. The long-term plan here will include all the ideas and features possible and that make logical sense to be included.

@thabaum I had a look at the issue, and I agree it's an issue. Responding to point 5, I would prefer:

User Display Name posted in group: Group Name Link Message

What if you would use static localization for this message (with tokens)?

[User:DisplayName] posted in: <a href="[GroupLink]">[Groupname]</a>

That way one can change the message as needed.

These templates are currently located in the Journal Resx file which means you can edit them. image

This is where I want to put the if statement to show or not show the group backlink depending on if there is a groupID on the page or not.

Then the next trick is to get the journal to post url and message title to itemData field. The Title database field does not get used except by creating groups logic. I will have to see how blog and forums use this by installing those mods. Title otherwise gets stuck in the Title section of a url. Maybe I need to make a category field in the db.

We will keep this open for discussion as I do want to improve the modules as desired by the community as I can. We will need to open up another issue regarding adding new fields to the journal posts displaying extra backlinks. The first step is to get the journal group posts to show as desired.

Bottom line unless there is an objection, I think I will move forward with 'User Display Name posted in group: Group Name Link Message'.

I think the others should say posted in forum: and posted in blog: but these again could be another PR, however we could fix this in this PR. You can edit this template now in your language files. Just understand the tokens only work on pages that have the module running if I am not mistaken. The tokens you see in the template are created by the Journal Module so you dont get the ones imported in from the forums or blog unless you are on a page that has those mods running. I may be wrong here let me know! Before you get too excited throwing down all the tokens created in modules and wonder why they are not working I just wanted to give a heads up. I get what you are both saying, and we are on track for it.

I will install the blog, events and forum module and test these out to make them all look uniform as a cherry on top of this PR if I have time.

Thanks again for the input, thumbs ups and all that for what has been shared. This helps clear some fog!

thabaum commented 2 years ago

To answer while asking my own question @valadas and @bdukes if I am correct, I can use javascriptas shown here (https://www.javatpoint.com/how-to-add-javascript-to-html) in the resx file I am hoping?

valadas commented 2 years ago

I would not recommend including javascript in resource files:

  1. It makes maintaining that code very hard
  2. It opens the door to all sorts of bugs and/or security issues
thabaum commented 2 years ago

Thanks @valadas that was also part of my concerns with using JavaScript here which is why I had to ask.

Then the switch will be done in the backend to another template file by using a new journal type id for posts created in a group and direct the new logic to switch the views. Show two different templates, the default journal_status.Text resx template showing while in group (could also make a journal_groupstatus.Text template) and a journal_grouppost.Text resx template showing up for activity feeds (when GroupId not set on a page).

Is this going to be legal to do here or maybe a better way to approach this in general? Trying get to work on this heading in the right general direction.

My other thought is like suggested earlier @Timo-Breumelhof of creating a Token if that makes sense that will be in the status template that prints the "posted in group: TITLE" if set, but is that logical?

I see two possibilities the community may accept and should work.

  1. Create 1 or 2 more templates for more control over how different posts get displayed in and out of the groups. Adding two new templates for group status and group post that get switched would be most preferred, Correct?

  2. Create a token[JournalGroupPost] in the journal_status.Text resx template that only displays info from a smaller resx file if information is set and not null and page group module GroupId is not present and journal module GroupId (which already gets set when a user makes a group post) is set on the journal entry? The item data can get inserted into the database for the group url and title. This should work since normal status posts do not have any item data, but a group status post can be allowed to collect, hold and then display it while staying the same journal type id. We will have a token that can display this information if set in the general template. Correct?

Just to be clear if I am understanding things accurately and expressing myself properly.

Can anyone shine a little light on what will get past the finish line? Version 1, 2 or ?

sleupold commented 2 years ago

I agree with @valadas and would make it more difficult for the translators.

thabaum commented 2 years ago

@david-poindexter I see a lot of documentation needed for elements that could clear up some build noise. https://docs.dnncommunity.org/api/

Is this where it needs to get documented? What is the process for documenting an element? I would like to try to help clean up some build noise from the easier stuff like documenting elements while I am working an area so we can see the more complex jobs to do like helping migrate obsolete items.

If this is what needs to happen is a PR adding a documentation file, maybe on the home of the API this process can be explained.

If I end up creating an element here for this PR I would like to document it as well properly. I would love it if someone else slapped out this PR solution and submitted it as well going off what is collected here. I have not started yet on my branch. Just digging into things to help. Thank you.

thabaum commented 2 years ago

It looks like we would need to get into the Journal_Types of the journal database and create a new one called groupstatus as JournalTypeId = 36; with JournalType = groupstatus; The logic for the group post will actually be in the journal instead of the module. 9 is only used for the group creation and 10 for group join. We need one for group status posts. image

            var journalTypeId = 1;  // "status" ?
            switch (postData.JournalType)
            {
                case "link":
                    journalTypeId = 2;
                    break;
                case "photo":
                    journalTypeId = 3;
                    break;
                case "file":
                    journalTypeId = 4;
                    break;
            }            
else
                {
                    rowTemplate = this.GetJournalTemplate(ji.JournalType, ji);
                }

In the DotNetnuke.Modules.Groups file GroupUtilities.cs I found this one method:

    public class GroupUtilities
    {
        public static void CreateJournalEntry(RoleInfo roleInfo, UserInfo createdBy)
        {
            var journalController = JournalController.Instance;
            var journalItem = new JournalItem();

            string url = string.Empty;

            if (roleInfo.Settings.ContainsKey("URL"))
            {
                url = roleInfo.Settings["URL"];
            }

            journalItem.PortalId = roleInfo.PortalID;
            journalItem.ProfileId = createdBy.UserID;
            journalItem.UserId = createdBy.UserID;
            journalItem.Title = roleInfo.RoleName;
            journalItem.ItemData = new ItemData { Url = url };
            journalItem.SocialGroupId = roleInfo.RoleID;
            journalItem.Summary = roleInfo.Description;
            journalItem.Body = null;
            journalItem.JournalTypeId = journalController.GetJournalType("groupcreate").JournalTypeId;
            journalItem.ObjectKey = string.Format("groupcreate:{0}:{1}", roleInfo.RoleID.ToString(CultureInfo.InvariantCulture), createdBy.UserID.ToString(CultureInfo.InvariantCulture));

            if (journalController.GetJournalItemByKey(roleInfo.PortalID, journalItem.ObjectKey) != null)
            {
                journalController.DeleteJournalItemByKey(roleInfo.PortalID, journalItem.ObjectKey);
            }

            journalItem.SecuritySet = string.Empty;

            if (roleInfo.IsPublic)
            {
                journalItem.SecuritySet += "E,";
            }

            journalController.SaveJournalItem(journalItem, null);
        }
    }
}

The line I see is journalItem.JournalTypeId = journalController.GetJournalType("groupcreate").JournalTypeId; with groupcreate used for a journal type to let the journal know to create an entry.

Now to get the one post journal type to use two templates depending on if a group module is present. The 1 = status template default for posts inside group pages and wall posts ie non-group journal status posts created on a page without a group module. The second new journal type 36 = groupstatus will get used when a journal item has a GroupID set for the status post and is on a journal module without a group module loaded on the page. groupstatus will be using the new journal language editable resx html template journal_groupstatus.Text. The group status template will be displaying the backlink which gets the journal item data and title set while making a post on a page with a journal module present.

For switching templates DotNetNuke.Modules.Journal.JournalParser.cs edit they file modifying the switching of templates located in this if else statement like the following as a general idea to start:

What I am trying to do here is see if there is a group module this.GroupId currently related to the journal module or if there is a journal entry group id ji.GroupId related to the journal entry to see what kind of status template it should use.

Maybe it should be called journal_statusgroup as it is a journal status object, however it is a group object as well and makes more sense if trying to find it to edit. I could be wrong here. Anyhow this is what I have in the works for logic.

For switching templates DotNetNuke.Modules.Journal.JournalParser.cs edit they file modifying the switching of templates located in this if else statement like the following as a general idea to start:

foreach (JournalItem ji in journalList)
            {
                string replacement = this.GetStringReplacement(ji);

                string rowTemplate;
                if ((ji.JournalType == "status") && (this.GroupId < 1) && (ji.GroupId >= 1))
                {
                    rowTemplate = groupstatusTemplate;
                    rowTemplate = TemplateRegex.Replace(rowTemplate, replacement);
                }                
                else if (ji.JournalType == "status")
                {
                    rowTemplate = statusTemplate;
                    rowTemplate = TemplateRegex.Replace(rowTemplate, replacement);
                }                    
                else if (ji.JournalType == "link")
                {
                    rowTemplate = linkTemplate;
                    rowTemplate = TemplateRegex.Replace(rowTemplate, replacement);
                }
                else if (ji.JournalType == "photo")
                {
                    rowTemplate = photoTemplate;
                    rowTemplate = TemplateRegex.Replace(rowTemplate, replacement);
                }
                else if (ji.JournalType == "file")
                {
                    rowTemplate = fileTemplate;
                    rowTemplate = TemplateRegex.Replace(rowTemplate, replacement);
                }
                else
                {
                    rowTemplate = this.GetJournalTemplate(ji.JournalType, ji);
                }
            }

I left a normal check for "status" without the other checks so there is a default if non pass the first status tests and still should be status template. Easier said than done but try saying all that in one breathe and does it make any sense? I will need to create a sql data provider if I can make this logic happen. For the sake of work load and simplicity I like just needing to create one more journal groupstatus resx template and just use the default journal status template. Maybe someone has a better solution, I will see what I can cook up in respect to what I now know.

Unless I hear some other feedback I will proceed this direction. My notes here will help explain all to maintainers if I put together a solution hopefully. Thank you everyone for all the help.

thabaum commented 2 years ago

Status update:

I did get a version of the above code to work for switching the group message on and off to a newly created journal_groupstatus in the resx file.

I just need to have the group posts that already set the id, also insert the same logic the database now while posting so that the group url and title information is connected to the post. I am not passing the objectkey or am I? I am making it work without it. I just set the Title and set the same journal item data that was in the group that was created. Seems to work good, this should be done soon :)

thabaum commented 2 years ago

For a recap:

To test I simply did the following:

  1. created a group.
  2. created a post inside a group (notice the groupid is set for the journal item in the database)
  3. copied the group created journal database ItemData and Title information to the post made in step 2 (the GroupID is set in the post already, that is how the magic works in the if statement for running the two different templates)

I will now work on the part that a journal inserting number 3. Make sense yet?

One new issue adding to the workload is the need to do this for file posted in group, pictured posted in group and link posted in group.

To Do:

I will put together a PR, but I am sure my first attempt will get shot down, or at least parts of it. I can see a few ways to handle things for example adding another database journal types entirely. I just think that since it is part of the journal module maybe it does not matter for this issue is about a part of the journals function while being used inside or out of a group module, not a forum's functions. Although some of this may enhance the ability for something like a forum to make category links from having a second Url2 and Title2 to work with. Then it can be a category link for a forum, with a title for the category and so on. I need to create something for the group link that needs created for all journal types at least. However for a group module I still feel I should be able to create this from the SocialGroupId the post was made and would lighten the workload a little not having to create anything new talking to the database.

thabaum commented 2 years ago

This is a bit of a task to pull off here for everyone and am working hard to make time soon.

I plan to enhance this part of DNN until satisfied then move into other parts of DNN, some long time pet peeve's of mine while being a general user pretty much the direction of things. I am just not sure I can make it by 10.3 as a few things with work pushing me back. I can't wait :) This will be a fun PR for me. I will be sure to get all the fixes in one so the latest two PR's can hold on if desired I submitted, however it maybe version 9.11 before I get the time it takes to get done for everyone. It is on my radar, and I will share my results when I work on it as a contribution. When it's done, I will post here as I feel I have enough to move forward with for now as far as community details. I have a feeling my first attempt with PR will fail in sense there are a couple ways I can handle this, and with failure comes success as I am sure someone from the community will point out the better direction, which was probably close to my other way I am thinking of handling things. I am confident by v10 for sure!

I guess my ONE question now that would help me sleep better on this is should I create new resx template typeID in the database that reference which templates to use or hard code them into the Journal source code?

A. Use the database templates called by typeID for journal_groupstatus, journal_grouplink, journal_groupfile, and journal_groupphoto templates with the backlink. I may need to make group_forumpost group_blogpost group_event and even a general group_post so then maybe I make group_status and group_link 'group_file`? I will create all that are needed to make this thing future proof and fit everyone's needs for posting things in a group, please I will give this time to marinate.

B. Set the source code to make the switch similar to how it uses the default templates and not worry about other use cases, just journal posts inside a group module. For other cases I think existing templates can add the newly created in this PR second Url2: and Title2: passed through JSON if it exists in the template file create it, if it is blank, so is the text for the link. You generally are never on the journal page and a forum at the same time. So then the above A is overkill. Just add the second link in the existing templates. If it is set, then it will get displayed. For status, links and files from the journal it needs to switch templates. I like this approach the most, however A could be most useful. While I am here I want to do the best I can for everyone.

C. Do something else that involves the switch in another way?

Hope some of that makes sense I know it is a lot to read, let alone write for input. I am just about to dump some serious time into this at some point, I want to be ready to rock when I do!

Another idea I have been passing around but not fully thought through yet originally was using a second template that gets included with all templates that gets parsed when a group module is not present producing a backlink for group posts which can point to a group at the top or bottom of a post and displayed only if it is not in a group, a product or whatever you feel that link is going to be with the title like a shopping cart item someone purchased back link to what they bought. After looking at code I figured A or B are more logical.

Bottom line is I want to enhance the module best I can with my abilities. I have some future stuff in mind but this is to start it all off and get a real understanding of what makes this thing tic.

I figure A is probably going to pass all critiques the best, but B would fly too potentially.

Sounds like I will be setting a second Url2: and Title2 in JSON, I am not sure what problems that will bring towards already existing modules with input already. I have some testing there to check things out more. Any special ways anyone wants the second Url and Title named I suppose talk now as I will be creating Url2 and Title2 to keep it simple.

I can make the switch case for it all and then point either or, however these would need created along with sql provider to help get those in place for use. The switch will change templates with the code I submitted above if I remember correctly. Besides "How" you do it, there is a choice here, and the community along with the developers should choose. It is more work to add to SQL, but if that is THE way, that is the way I will do it. If community is ok with it switching inside the source code to the resx template.

Food for thought!

Thank you all for helping support the DNN Project! <3

stale[bot] commented 2 years ago

We have detected this issue has not had any activity during the last 90 days. That could mean this issue is no longer relevant and/or nobody has found the necessary time to address the issue. We are trying to keep the list of open issues limited to those issues that are relevant to the majority and to close the ones that have become 'stale' (inactive). If no further activity is detected within the next 14 days, the issue will be closed automatically. If new comments are are posted and/or a solution (pull request) is submitted for review that references this issue, the issue will not be closed. Closed issues can be reopened at any time in the future. Please remember those participating in this open source project are volunteers trying to help others and creating a better DNN Platform for all. Thank you for your continued involvement and contributions!

stale[bot] commented 2 years ago

This issue has been closed automatically due to inactivity (as mentioned 14 days ago). Feel free to re-open the issue if you believe it is still relevant.