Charging Points to Add Image and Add Video

Post

Posted
Rating:
#5721

How to disallow adding images and videos based upon points.

Yes, working on it.

Post

Posted
Rating:
Item has a rating of 1
#5722
Attachment

cms-galleries-changes.diff

Post

Posted
Rating:
Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 (Liked by Adam Edington)
#5723
Chris, that was absolutely amazing!

I thought it was an easy fix.  I didn't realize it meant coding the entire page.

Wish I had more points to give you (I recently joined).  You deserve more!

I can't thank you enough!!!

Post

Posted
Rating:
#5724
I am almost too embarrassed to post anymore on this topic, as Chris Graham graciously spent so much time, posted a lesson, and programmed the entire page that required changing.  However, I have to ask.....how do you use a diff file?  I have never seen one or used one.  What do I do with it?

I'm also still confused about the line:
           if ((!has_privilege(get_member(), 'have_negative_gift_points')) && (available_points(get_member()) < -$points)) {
               return false;


I am still not sure why gift_points are mentioned, since image and video uploads are deducted from Current Points, not Gift Points.  If the operator '&&' is used, doesn't it mean that both operands are true.  Let's say a user has a positive number of Gift Points and not enough Available Points (they are separate).  They shouldn't be able to upload an image due to the lack of available points.  Would they still be able to upload because they had positive gift points (which has nothing to do with the upload)?

Thanks again!

Post

Posted
Rating:
#5730
Pasted copy of cms_galleries file in modules_custom.  I added the changes manually. 

Logged in as a user.  Clicked button to upload IMAGE.  Gave me message when I didn't have enough points.  Great.

Clicked button to upload VIDEO.  Critical error - bailing out

I deleted the copy of the cms_galleries file because there was a black bar in my cpanel.

I don't know if this has anything to do with it, but when I hover over the "Add image" link the type=add, and when I hover over the "Add video" link the type=add_other.

Image

(Click to enlarge)

Post

Posted
Rating:
Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 (Liked by Adam Edington)
#5731
For anyone else following this topic, the Composr CMS Twitch channel (

Twitch

Twitch is the world's leading video platform and community for gamers.

View

) has the session we did. This was the first time I did something on Twitch, so it was somewhat experimental, but I think it worked really well. I've been thinking for a while that this kind of approach might work well. Going back-and-forth on forum topics can be very time consuming and frustrating and usually only helps 1 person a bit. A video shows a lot more, is a resource to more people, likely does a better job of making sure harder goals are met, and yet actually may end up taking less time (which is definitely finite on my end). I plan to take this and future videos and put them up on the YouTube channel permanently as coding workshops.

Now, replying to further posts in this topic…

I didn't realize it meant coding the entire page.

Well, it was only a few lines of code. But to be honest I have always thought there was an optimism bias in the Composr community as to how easy implementing custom ideas is ;-). If we look at all the code written for the Composr project, it's around 850,000 lines at the moment. And I for one write pretty terse code, so there's a lot of logic packed into that, other projects would probably take millions to do the same.

how do you use a diff file

If you do want to apply it automatically (I expected hand application), you use the patch command, which comes with Mac OS and Linux, and if you're on Windows I think you could get it with Cygwin (Cygwin).

You'd make sure the working directory was the Composr base directory (as this is where I created the diff file from, and hence where file paths are relative to). And then:

Code (Bash)

patch -p1 < somefile.diff
 

I am still not sure why gift_points are mentioned, since image and video uploads are deducted from Current Points, not Gift Points.

Right, I tried to cover this in the video but I was probably confusing. There's no direct privilege for negative points, but I used this one for negative gift points by mistake.
I just confirmed in the code we currently use give_points_self for a negative points privilege - as I mentioned in the video, being able to give yourself points is basically the same thing as being allowed negative points, in effect. So change have_negative_gift_points to give_points_self.

If there's any remaining confusion, the lines should be:

Code (PHP)

if ((!has_privilege(get_member(), 'have_negative_gift_points')) && (available_points(get_member()) < -$points)) {
    return false;
}
 

which means "If the current user does not have the "give_points_self" privilege and has fewer points than the cost [the negative of what they'll be given], say they won't be allowed to submit.".

Clicked button to upload VIDEO.  Critical error - bailing out

Whoops. That was totally my mistake. I added new methods (class functions) into the first class in the file (Module_cms_galleries), but videos are in a second class (Module_cms_galleries_alt).
I don't want to get too deep in the weeds of how to do this correctly, so for now I'd suggest just copying and pasting my has_enough_points and check_available_points methods so they are also in Module_cms_galleries.

Post

Posted
Rating:
#5740
Thanks again Chris!

The session on Twitch was excellent!  For those reading this, if you go to the twitch.tv website and search for ComposrCMS, you will find the video.  You don't have to join to view it.  I've already watched it a few times.  If you want to participate in a chat during a live session, you will have to join.  Chatting during a live session on a full screen changed the chat box.  That's why it took me a while to change it back to respond to you Chris. 

I am still getting a Critical Error message when adding a video without enough points.  I am so sorry but I am not understanding what I need to do, what to add, and where.

I'd suggest just copying and pasting my has_enough_points and check_available_points methods so they are also in Module_cms_galleries.


Your patience is much appreciated!

Last edit: by starfish

Post

Posted
Rating:
Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 (Liked by Adam Edington)
#5741
IT WORKS!!!

I don't know why I didn't understand what you said at first, Chris.  I am so grateful for everything you did!!!

Please let us know when you are doing your next Twitch tutorial.

Post

Posted
Rating:
Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 (Liked by Adam Edington)
#5745
Next Twitch tutorial will be very much based on whether something comes up that requires it. Right now my priority is maintaining v10 and getting v11 finished.
0 guests and 0 members have recently viewed this.