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

Using xenforo permission outside of xenforo?

Discussion in 'XenForo Development Discussions' started by Member 3639, Nov 3, 2010.

  1. Member 3639

    Member 3639 Active Member

    Hi all currently using PHPBB on my website Gaming On Linux and i am thinking about switching over.

    First Question
    My main concern is that everything on the main website that is user based uses phpbbs auth system, how easy is it to see/use the authorisation system of xenforo outside of it?

    Like a certain user group say admins, super mods or even an admin created group.

    Like including certain files then doing say (dirty example)
    if ($auth->group['admin'] == 1)
    // do something
    Is it simple enough with xenforo?

    Second question
    How easy is it to get videos to be able to be embeded via bbcode in posts from popular sites like youtube or veoh?
  2. steven s

    steven s Well-Known Member

    Q1. Don't know.
    Q2. As easy as clicking on the media button.
  3. Decent60

    Decent60 Well-Known Member

    It's quite easy to do an admin group and a moderator group:
    <xen:if is="{$visitor.is_admin}">
    //do something, you c an also use is="{$user.is_admin}" or is="{$user.is_moderator}" or is="{$user.is_admin} OR {$user.is_moderator}"
    All Admins or Moderators needs put in the Administrator or Moderator group, regardless of rank (even admin rank needs to be put in the Administrator group).
    I really never found how to do a specific group id, but it should be fairly easy....depending on what you want to do that is.
  4. Member 3639

    Member 3639 Active Member

    I'm not talking inside templates though as that looks like it's from a template, I'm talking outside the script - like website integration using xenForo permissions.
  5. Decent60

    Decent60 Well-Known Member

    Ah, sorry then. I don't know that answer. I just know the simple stuff with coding. Sorry man.
  6. Member 3639

    Member 3639 Active Member

    Can anyone else like the devs comment on this?
  7. James

    James Well-Known Member

    Hi Liam. Are you wondering because of certain custom pages that you want to port over or just in general? If it's the former, look at the pages system on XF and see if that suits your needs until the devs can get back to you.
  8. Member 3639

    Member 3639 Active Member

    I mean outside the forum entirely.

    So on my actual website if a user is logged into the xenForo forum i can check certain permissions to allow them to do certain things on the website.
  9. Jeremy

    Jeremy Well-Known Member

    As long as the environment is set up correctly (by including it. I'm not 100% certain HOW to set it up correctly) or if you rework everything to be under your forum index.php, you can very easily access everything.
  10. Member 3639

    Member 3639 Active Member

    I'm not willing to re-code my site to work under a file of the forum.

    On PHPBB you do need to include a file or two and then do a tiny bit of code.

    Just wandering if you can do the same in xenForo, guess i need a dev to comment on this really.

    Things like showing "welcome <username>" on your website if they are logged in, stuff like that.
  11. Mike

    Mike XenForo Developer Staff Member

    There is some code that is stuck in controllers that probably shouldn't be. Moving that out would make it a lot easier to do. That is something I will look at. After that, it'd be setting up the environment (autoloader and application bootstrap), then grabbing the session and current visitor info. From there, there are model calls to check various permissions (though you can call the individual pieces more directly if you want).
    Shadab and (deleted member) like this.
  12. Member 3639

    Member 3639 Active Member

    Well a lot of people will be needing something like this no doubt, would be worth it to make it easier for us to do it.

    Maybe add info to faq or mod guide or something?
  13. Shadab

    Shadab Well-Known Member

    I'm bridging my symfony based applications with xenforo, and so far session handing seems to be the only problematic part. Processing of the Remember Me logic would require code duplication, since (like you've said) it's originally located in the abstract controller class. Any chance of moving this logic to the session class itself?

    If I skip the code for processing Remember Me, setting up the framework including session and visitor takes just about 10 lines of code. Very easy & simple. :)
  14. Mike

    Mike XenForo Developer Staff Member

    That was the main bit I was referring to, though I'd have to double check approach as there is different code for ACP and front-end sessions (they are distinct). :) There are a few other helper type things that could be moved too.
    rthrash and Decent60 like this.
  15. Member 3639

    Member 3639 Active Member

    Any update on this at all?

    Would really like for an easy way to get a persons username, permission level etc outside of the forum.
  16. s2kinteg916

    s2kinteg916 New Member

    I would love to get this answered as well. this is a very important aspect of deciding to move to xenforo
  17. airworks

    airworks Member

    Interested in knowing the same thing. Would you be able to use xenforo and zend frameworks outside of the forum as well?
  18. Member 3639

    Member 3639 Active Member

    As an example in phpbb you would do this:
    define('IN_PHPBB', true);
    $phpbb_root_path = './community/';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);
    // Start session management
    Then you can access all the user info.

    So for username:
  19. Shadab

    Shadab Well-Known Member

    As a stop-gap measure, I've created a helper class that you can call to initialize the xenforo application, preload the important data and setup the session properly, taking auto-login into consideration. Let me know (via PC) if you want it. (Although it would become redundant once the code is moved to a helper in xenforo core).

    Sample code for that:
    $startTime microtime(true);
    $xenforoRoot '/absolute/path/to/xenforo/root/directory';

    // Setup XenForo's autoloader
    require_once($xenforoRoot '/library/XenForo/Autoloader.php');
    XenForo_Autoloader::getInstance()->setupAutoloader($xenforoRoot '/library');

    // Initialize the XenForo Framework

    // You can fetch user data using the visitor object
    $visitor XenForo_Visitor::getInstance();

    $user_id $visitor->getUserId();
    $username $visitor->get('username');
    $email $visitor->get('email');
    Ajaxboy, Eric Winter and Member 3639 like this.
  20. Member 3639

    Member 3639 Active Member

    Brilliant, have you tested it working?

    Are you able to check their permission levels? So you can check if someones admin to let them into an admin centre for a website?

Share This Page