1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Question on "Awaiting Approval" count

Discussion in 'XenForo Development Discussions' started by Trombones13, Jan 13, 2011.

  1. Trombones13

    Trombones13 Well-Known Member

    This thread will kinda make it obvious (my surprises are always ruined by questions! :(), but I'm working on a little tweak to show the number of users "Awaiting Approval" in the moderator bar. However, I can't figure out how to make the count for the number of users awaiting approval to appear on the frontend. I presume it's something similar to this, which is the display/count for reported items on the moderator bar:
    Code:
    <a href="{xen:link reports}" class="reportedItems modLink">
    				<span class="itemLabel">{xen:phrase reported_items}:</span>
    				<span class="itemCount {xen:if {$session.reportCounts.total}, 'alert'}">{$session.reportCounts.total}</span>			</a>
    However, I don't know what the class and itemCount conditional should be set to instead of reportCounts. Is this going to require a file change, or is it just a matter of having the correct class in the code?
     
    Ranger375 likes this.
  2. ragtek

    ragtek Guest

    AFAIK the value is not available in the frontend
    YOu'll need to run
    PHP:
    $userModel->countUsers(array('user_state' => 'moderated')),
    and assign the value to the view.

    IMHO the best point for this would be container_public_params
     
    Trombones13 likes this.
  3. Trombones13

    Trombones13 Well-Known Member

    Thanks! I'll attempt to get it working later tonight (gotta check out the old Have You Seen? videos and make sure I know what I'm doing...I think the pagenav one has me close to finished already) and post back if I have further issues. :D
     
  4. Trombones13

    Trombones13 Well-Known Member

    Apparently I'm doing something wrong, because I'm getting the "Please enter a valid callback method." error. :(

    Listening to event: controller_public_params
    Callback: KurtApproveBar_Listener_count::count (had ::listen there before, but that didn't work either)

    File library/KurtApproveBar/Listener/count.php:
    PHP:
    <?php

    class KurtApproveBar_Listener_count
         
    {
         public static function 
    count(array &$params}
         {
             
    $userModel->countUsers(array('user_state' => 'moderated')),
         }
    ?>
    Help would be appreciated...I think I might hopefully be sorta close (how's that for confident? haha) thanks to Kier's video and Lawrence's guide, but I'm not sure what's going wrong here. :/
     
  5. ragtek

    ragtek Guest

    There is o userModel available in the scope;)

    You could try
    class KurtApproveBar_Listener_count
    {
    public static function count(array &$params}
    {
    $userModel= XenForo_Model::create('XenForo_Model_User');
    $userModel->countUsers(array('user_state' => 'moderated')),
    }
     
  6. Trombones13

    Trombones13 Well-Known Member

    Still getting the "Please enter a valid callback method" error. :( Does that mean it has to do with what I've put in for KurtApproveBar_Listener_count::count? :confused:
     
  7. Ranger375

    Ranger375 Well-Known Member

    Please share when you get it working, I have been trying to figure this out lol!
     
  8. ragtek

    ragtek Guest

    donate xxx$ to paypal account ragga@ragtek.org:p
    then download the attachment, unpack & upload it, install the xml file
    place {$appcounter} into your template
    check if it's working
    say thx
     

    Attached Files:

    adin likes this.
  9. ragtek

    ragtek Guest

    I'm not sure what you're doing and i don't have the time to discuss about it, so if you're interessted in coding, check the code;)
    If not, install it^^
     
  10. Trombones13

    Trombones13 Well-Known Member

    I want to figure it out, so I'll keep fiddling around--thanks for your help. :)
     
  11. ragtek

    ragtek Guest

    my code:
    PHP:
    <?php
    class Ragtek_ApproveMember_StaticMethods{

        public static function 
    addGlobalAppMembers(&$params$dep){
            
    $memberModel XenForo_Model::create('XenForo_Model_User');
            
    $params['appcounter'] = $memberModel->countUsers(array('user_state' => 'moderated'));
        }
    }
    Listenersettings:
    event.PNG
     
    Rudy and Trombones13 like this.
  12. Trombones13

    Trombones13 Well-Known Member

    *pumps fist in air*
    The only reason why this wasn't working (well, after I fixed the code--didn't have "$dep" or the "params" thing done correctly) was because when I upload things to the server via FireFTP, I have to fix the permissions...and I hadn't remembered to do so until just a moment ago, hence why I was receiving the "Please enter a valid callback method" errors. It's working now:
    XF Awaiting Approval Pic.png
    Thanks a bunch for your help, ragtek! :D
     
  13. ragtek

    ragtek Guest

  14. Rudy

    Rudy Well-Known Member

    Downloaded the attachment, but the readme.html file says to upload everything in the /upload directory, then install the .xml file. Do we still need to place {$appcounter} in the template? May want to update that readme.html file if so.
     
  15. ragtek

    ragtek Guest

    I think that we have already a other version of this add-on (with automatic template including in the modbar)
    I'll check it when i'm in the office and if it's so, i hope that ajnos can release it here.
     
  16. Rudy

    Rudy Well-Known Member

    That would be great--I'll wait for your reply!
     
  17. Rudy

    Rudy Well-Known Member

    A "bimp" for this thread...even if I get code for the template edit to put this up in the moderator bar, it would work for now. I have the rest of the plugin installed but disabled.

    I can put "{$appcounter}" in the moderator bar, but nothing appears. If I highlight the area with the mouse, though, i can see the number of unapproved users. All it needs is a little extra code to go with this in the template, and it would be ready to go.
     
  18. mrGTB

    mrGTB Well-Known Member

    I would like to see this added as a default part of XenForo before 1.1 Gold. It's very much needed as an instant indicator on the front-page without having to keep venturing into the back-end to check things each time.
     
    Phillip likes this.
  19. Shelley

    Shelley Well-Known Member

  20. Rudy

    Rudy Well-Known Member

    Agreed. Moderators on my forums usually don't have time to check the new member queue several times per day--the Awaiting Activation mod we put in place is used constantly and we get members approved much faster.

    I'm OK with it being an add-on but would be nice to have it be part of XF proper, especially since the additional code is so minimal.
     
    Phillip likes this.

Share This Page