Go Back   vb.org Archive > vBulletin 5 Connect Discussion > vB5 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-05-2017, 06:24 AM
userform3 userform3 is offline
 
Join Date: Jul 2010
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default New extension, does not work!

Hi,

In forum, vbulletin version 5.2.5, I would like to create a new extension.

To the facts, the forum is only accessible to registered users, if a user is not registered, he can see the forum, not.
If the user is registered, his real first name and last name should be displayed.
These data are located in a separate table in the forum database and must be read out additionally.

To implement this, we introduced a new product in the area "Products & Hooks" in "Manage Products" with the name "klarnamenIntern".
A new add-on was created in "Manage Hooks". To test with "klarnamen".
In the directory .../forum5/core/packages/klarnamenIntern the following directories with files were created:

HTML Code:
klarnamenIntern/api/site.php
klarnamenIntern/xml/product_klarname.xml
product.php
Unfortunately, I can not access the forum data via the procedure described above.
That is, About the file klarnamenIntern/api/site.php I can not read posts from the forum.

What is the error or the causes why I can not access the data?
How can I access the PHP files klarnamenIntern/api/site.php from the forum or connect?

Example the file klarnamenIntern/api/site.php
PHP Code:
<?php if(!defined('VB_ENTRY')) die('Access denied.');

class 
Interred_Api_Site extends vB_Api_Extensions 
{
    protected 
$product 'klarnamenIntern';
    protected 
$developer 'die-user';
    protected 
$title 'Global';
    protected 
$minver '5.2.0';    
    protected 
$AutoInstall 2;
    protected 
$extensionOrder 10;
    
    function 
__construct () {
        
$this->fetchThreads();
        
        
// Only the default data is taken from the forum
        
$forum $this->do_get_forum();
        echo 
"<pre>forum:: " .print_r$forumtrue ). "</pre><hr>";        
    }
    
    public static function 
fetchThreads(){ 
        
// Only user data, which is calling the forum!
        
$userinfo vB_Api::instance('user')->fetchUserInfo();
    }
    
    
// ##########################################
    // From here, methods taken from another extension.
    
    
public static function do_get_forum_data()
    {
        
$cleaned vB::getCleaner()->cleanArray($_REQUEST, array(
            
'forumids' => vB_Cleaner::TYPE_STR,
        ));

        if (!isset(
$cleaned['forumids']) || strlen($cleaned['forumids']) == 0) {
            return array(
'forums' => array());
        }

        
$forumids explode(','$cleaned['forumids']);

        
$forum_data = array();

        foreach (
$forumids AS $forumid) {
            
$forum self::fr_get_and_parse_forum($forumid);
            if(
$forum != null) {
                
$forum_data[] = $forum;
            }
        }

        if(!empty(
$forum_data)) {
            return array(
'forums' => $forum_data);
        } else {
            return 
null;
        }
    }
    
    function 
fr_get_and_parse_forum($forumid$foruminfo false)
    {
        
$userinfo vB_Api::instance('user')->fetchUserInfo();
        
$options vB::get_datastore()->get_value('options');

        if(!
$foruminfo) {
            
$foruminfo vB_Api::instance('node')->getFullContentforNodes(array($forumid));
            if (empty(
$foruminfo)) {
                return 
null;
            }
            
$foruminfo $foruminfo[0];
        }
        if(!
$foruminfo) {
            return 
null;
        }

        
$type 'old';

        if (
$options['threadmarking'] AND $userinfo['userid']) {
            
$userlastvisit = (!empty($foruminfo['readtime']) ? $foruminfo['readtime'] : (vB::getRequest()->getTimeNow() - ($options['markinglimit'] * 86400)));
        } else {
            
$lastvisit vB5_Cookie::get('lastvisit'vB5_Cookie::TYPE_UINT);
            
$forumview fr_fetch_bbarray_cookie('channel_view'$foruminfo['nodeid']);

            
//use which one produces the highest value, most likely cookie
            
$userlastvisit = ($forumview $lastvisit $forumview $lastvisit);
        }

        if (
$foruminfo['lastcontent'] AND $userlastvisit $foruminfo['lastcontent']) {
            
$type 'new';
        } else {
            
$type 'old';
        }

        
$out = array(
            
'id' => $foruminfo['nodeid'],
            
'new' => $type == 'new' true false,
            
'name' => html_entity_decode(strip_tags($foruminfo['title'])),
            
'password' => false// No forum passwords in vB5
        
);

        
$icon self::fr_get_forum_icon($foruminfo['nodeid'], $foruminfo == 'new');
        if (
$icon) {
            
$out['icon'] = $icon;
        }

        if (
$foruminfo['description'] != '') {
            
$desc strip_tags($foruminfo['description']);
            if (
strlen($desc) > 0) {
                
$out['desc'] = $desc;
            }
        }
        return 
$out;
    }
    
    function 
fr_get_forum_icon ($forumid$shownew$showlink=false)
    {
        
$basedir MCWD '/icons/';

        
$new $old $link null;

        if (@
file_exists($basedir 'forum-default-new.png')) {
        
$new 'forum-default-new.png';
        if (@
file_exists($basedir 'forum-default-old.png')) {
            
$old 'forum-default-old.png';
        } else {
            
$old $new;
        }
        }
        if (@
file_exists($basedir 'forum-default-link.png')) {
        
$link 'forum-default-link.png';
        }

        if (@
file_exists($basedir 'forum-' $forumid '-new.png')) {
        
$new 'forum-' $forumid '-new.png';
        if (@
file_exists($basedir 'forum-' $forumid '-old.png')) {
            
$old 'forum-' $forumid '-old.png';
        } else {
            
$old $new;
        }
        }
        if (@
file_exists($basedir 'forum-' $forumid '-link.png')) {
        
$link 'forum-' $forumid '-link.png';
        }

        return (
$showlink $link : ($shownew $new $old));
    }
}
?>

greetings
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:46 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04651 seconds
  • Memory Usage 2,223KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_html
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete