Charging Points to Add Image and Add Video

Post

Posted
Rating:
#6337
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’

How to disallow adding images and videos based upon points.

Yes, working on it.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 1
#6338
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Attachment

cms-galleries-changes.diff



Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Adam)
#6339
Avatar
Standard member
starfish is in the usergroup ‘Fan in action’
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!!!
Online now: No Back to the top

Post

Posted
Rating:
#6340
Avatar
Standard member
starfish is in the usergroup ‘Fan in action’
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!
Online now: No Back to the top

Post

Posted
Rating:
#6348
Avatar
Standard member
starfish is in the usergroup ‘Fan in action’
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)

Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Adam)
#6349
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
For anyone else following this topic, the Composr CMS Twitch channel (Twitch) 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.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#6359
Avatar
Standard member
starfish is in the usergroup ‘Fan in action’
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

Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Adam)
#6363
Avatar
Standard member
starfish is in the usergroup ‘Fan in action’
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.
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Adam)
#6368
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
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.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Users online:

Philip, MVLipwig, Paul D, mytracker, deepu_ms, Salman, amit.nigam, ManojSree

Forum statistics:
  • 1,174 topics, 5,550 posts, 6,746 members
  • Our newest member is waqasf160
Birthdays:
Back to Top