Need A User Individual Action Stat Keeper

clyde alan Posted in Component Development 6 years ago

Hey thanks developers this is awesome. Im not very knowledgeable in php. Ive been wanting to realize an idea of mine for a while to pitch... i think. anyways

what i was wanting to do is add a stat to a userstats table every time an individual action is made.
ie:
Like, Dislike(Separate for photos and word posts), making a post, replying to a post.

I have wrote my php script with the functions i need to do this.

I just do not know where to insert them or if im allowed

Replies
us Rishi B Replied 6 years ago

um, isn't that what I said?

"Right now this only updates the ossn-users table with the time of the last activity, but you could make it save the last action pretty easily..."

No one here is going to do the work for you, I already told you where to look. That function, update-last-activity() is called in system/start.php. That file has all the information on what user action is being performed because it's always the first file that gets hit (and then modrewrite takes care of making the url nice). You're going to want to add either a separate table (if you want to save every action) or an extra field for "lastaction" in ossn-users if you only care about the most recent action.

us Clyde alan Replied 6 years ago

Thanks, but I had already visited those links before making this post. I meant to respond sooner. I already have it setup as a component. I've added all of my functions for editing the tables I'm storing all of my data in the ossn_com.php.

My assumption of this component setup is that I can now call my functions throughout the ossn pages. Basically its automatically including it for me.

As far as I can tell the updatelastactivity() is only making a timestamp of the last time you load a page. No information on what the user was doing.

My current plan is to call my functions in each of the components in which stats will be generated. Then I will have to play with a it a little to find the best place to inject my code to make sure there's no easy way to cheat the stats.

I've been watching some php & css tutorials and your direction to the start.php helped. I learned HTML in the 90s when I was a teenager. I played with stuff like Visual Basic 3.0 and made simple websites to distribute my programs. After I got hit by the real world I fell out of it. I just need to learn a little more and try again. I have a basic understanding of how programming works, so I can usually crack it after a while.

Thanks again

us Rishi B Replied 6 years ago

for purposes of seeing how things work, you may want to look at OssnUser->updatelastactivity(). Right now this only updates the ossn-users table with the time of the last activity, but you could make it save the action pretty easily obviously. It's still recommended that you make additions/modifications via the use of components rather than directly editing files, but that should give you an idea of how things work. This function gets called in system/start.php, which is why it correctly saves the time of every user action.

us Rishi B Replied 6 years ago

OSSN is open source so of course you can edit the code. You should write this as a component, I think it's a cool idea.

Here's information on publishing your completed component to this website for others to download: https://www.opensource-socialnetwork.org/wiki/view/2022/how-to-publish-a-component

And here's information on how to write a component in PHP: https://www.opensource-socialnetwork.org/wiki/view/737/how-to-write-a-simple-component-for-ossn

This may also be helpful: https://www.opensource-socialnetwork.org/wiki/view/739/naming-convention-for-creating-components