Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-20-2014, 03:02 AM
ETS|LuucEarth ETS|LuucEarth is offline
 
Join Date: Jul 2014
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Proiblems with Templater after datamager thread post

Im creating a custom Post-Registration Application system for our use.

On submit all the info is stored in custom profile fields, A post is made with the information in our application review forum.

However Im having a problem with the Template in this system.

If I render the template before the post the post doesnt happen.
If I render the template after the post, the render doesnt happen. IE Blank white page
PHP Code:
    $threaddm = new vB_DataManager_Thread_FirstPost($vbulletinERRTYPE_STANDARD);
    
$threaddm->set_info('forum',$foruminfo);
    
$threaddm->set_info('user'$vbulletin->userinfo);
    
$threaddm->set('forumid'$forumid);
    
$threaddm->set('userid'197);
    
$threaddm->set('title'$threadtitle);
    
$threaddm->set('pagetext'$formoutput); 
    
$threaddm->set('open'TRUE);
    
$threaddm->set('allowsmilie'TRUE);
    
$threaddm->set('visible'TRUE);
    
$threaddm->pre_save();
    
$threadid $threaddm->save();
    unset(
$threaddm);
    
build_thread_counters($threadid);
    
build_forum_counters($forumid); 
PHP Code:
        $navbits construct_navbits($navbits);
        
$navbar render_navbar_template($navbits);
        
$templater vB_Template::create('ets_tester_application_submit');
        
$templater->register_page_templates();
        
$templater->register('navbar'$navbar);
        foreach(
$userdata as $key=>$value){
        
$templater->register($key,$value);
        }
        
print_output($templater->render()); 
Anyone have any ideas on this?
Reply With Quote
  #2  
Old 11-20-2014, 08:20 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, the reason you don't see the post if you render first is because print_output() exits the script, so it doesn't return. Maybe the reason you get a blank page if you render last is because something before it is causing an error, but I don't see offhand what's wrong. If error messages are turned off, maybe you're not seeing the error message?

Edit: if you're seeing the post when you post first, then maybe that means the problem is with one of the build counter functions. Maybe you need to inlcude includes/functions_databuild.php?
Reply With Quote
  #3  
Old 11-20-2014, 10:16 AM
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Jul 2009
Location: USA
Posts: 10,929
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is what I use in my mods to make the post, build the thread counters, and if chosen, update the posters post count..

PHP Code:
if ($vbulletin->options['ozzmodz_welcome_thread_active'] AND $vbulletin->options['ozzmodz_welcome_thread_auto_post_email_verify'] == 0)
{
                
        
// Some Declarations
        
global $vbphrase;

        
$postmessage = array(
            
'pagetext1' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_one'],
            
'pagetext2' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_two'],
            
'pagetext3' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_three'],
            
'pagetext4' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_four'],
            
'pagetext5' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_five'],
            
'pagetext6' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_six'],
            
'pagetext7' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_seven'],
            
'pagetext8' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_eight'],
            
'pagetext9' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_nine'],
            
'pagetext10' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_ten']
        ); 
        
$rand_text array_rand($postmessage);

        
$title = array(
            
'title1' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_one'],
            
'title2' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_two'],
            
'title3' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_three'],
            
'title4' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_four'],
            
'title5' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_five'],
            
'title6' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_six'],
            
'title7' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_seven'],
            
'title8' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_eight'],
            
'title9' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_nine'],
            
'title10' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_ten']
        ); 
        
$rand_title array_rand($title);                                        

        
// Needed Classes
        
require_once(DIR .'/includes/class_dm.php');
        require_once(
DIR .'/includes/class_dm_threadpost.php');
        require_once(
DIR '/includes/functions_databuild.php');
        
$threaddm datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost');
            
        
$userdata $vbulletin->db->query_first("
            SELECT u.username,u.userid
            FROM " 
TABLE_PREFIX "useractivation AS ua
            LEFT JOIN " 
TABLE_PREFIX "user AS u USING (userid) 
            WHERE ua.activationid = '" 
$vbulletin->db->escape_string($vbulletin->GPC['i']) . "'       
        "
);
        
        
$useridnumber $vbulletin->db->query_first("
            SELECT userid
            FROM " 
TABLE_PREFIX "useractivation
            WHERE activationid = '" 
$vbulletin->db->escape_string($vbulletin->GPC['i']) . "'
            
        "
);           

        
// Some Variables
        //Registered Name
        
$username htmlspecialchars_uni($userdata['username']);
        
//Registered Userid for DBTECH's AUT Mod
        
$mentionuserid $useridnumber['userid'];
        
//Post Icons
        
$posticons_get explode(","$vbulletin->options['ozzmodz_welcome_thread_auto_post_post_icon']);
        
$posticons $posticons_get[array_rand($posticons_get)];
        
//Forum ID To Post To
        
$forumid $vbulletin->options['ozzmodz_welcome_thread_auto_post_forumid'];
        
//Posters ID
        
$postuserid $vbulletin->options['ozzmodz_welcome_thread_auto_post_userid'];
        
//Posters ID?
        
$userid $vbulletin->options['ozzmodz_welcome_thread_auto_post_userid'];
        
//Posters Username
        
$usernames $db->query_first("
            SELECT username 
            FROM " 
TABLE_PREFIX "user 
            WHERE userid = " 
intval($userid));
        
$username2 $usernames['username'] ? $usernames['username'] : 'Guest';
        
//Site Title
        
$bbtitle $vbulletin->options['bbtitle'];
        
//Site URL
        
$url $vbulletin->options['bburl'];
                
$userid2 $useridnumber['userid'];

$vboptions $vbulletin->options;
$bbuserinfo $vbulletin->userinfo;

        
//Post Content
        
$pagetext str_replace(array('$username''$url''$bbtitle''$mentionuserid'), array($username$url$bbtitle$mentionuserid), $postmessage);    
        
//Post Title
        
$title str_replace(array('$username''$url''$bbtitle'), array($username$url$bbtitle), $title);
        
//Allow Smiles (No Option)
        
$allowsmilie '1';
        
//Show Signature (No Option)
        
$showsignature '1';
        
//Moderated (No Option)
        
$visible '1';
        
//Open To Replies
        
$open $vbulletin->options['ozzmodz_welcome_thread_auto_post_close_thread'];
        
//Sticky Thread
        
$sticky $vbulletin->options['ozzmodz_welcome_thread_auto_post_sticky'];
        
//Thread ID To Post To
        
$threadid $vbulletin->options['ozzmodz_welcome_thread_auto_post_thread'];
        
//Thread Counters To Build
        
$threadids $vbulletin->options['ozzmodz_welcome_thread_auto_post_thread'];
        
$ipaddress '000.000.000';

        if (
$vbulletin->options['ozzmodz_welcome_thread_auto_post_how'] AND $userdata['username'] !='')
        {
            
$threaddm datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost');
            
// Write Into Post Table
            
$threaddm->do_set('forumid'$forumid);
            
$threaddm->do_set('postuserid'$postuserid);
                        
$threaddm->do_set('ipaddress'$ipaddress);
            
$threaddm->do_set('userid'$userid);
            
$threaddm->do_set('title'$title[$rand_title]);
            
$threaddm->do_set('pagetext'$pagetext[$rand_text]);
            
$threaddm->do_set('username'$username2);
            
$threaddm->do_set('open'$open);
            
$threaddm->do_set('sticky'$sticky);
            
$threaddm->do_set('iconid'$posticons);
            
$threaddm->do_set('allowsmilie'$allowsmilie);
            
$threaddm->do_set('showsignature'$showsignature);
            
$threaddm->do_set('visible'$visible);
            
$threaddm->pre_save();
            
            if(
count($threaddm->errors) < 1)
            {
                
$threadid $threaddm->save();
                unset(
$threaddm);
                
build_thread_counters($threaddm);
            }
    
             
build_forum_counters($forumid);
        }
        else
        {
            
$threaddm datamanager_init('Post'$vbulletinERRTYPE_ARRAY'threadpost');
            
// Post As A Reply To A Post
            //$threaddm->do_set('forumid', $forumid);
            
$threaddm->do_set('threadid'$threadid);
                        
$threaddm->do_set('ipaddress'$ipaddress);
            
$threaddm->do_set('parentid'$parentid);
            
$threaddm->do_set('userid'$userid);
            
$threaddm->do_set('title'$title[$rand_title]);
            
$threaddm->do_set('pagetext'$pagetext[$rand_text]);
            
$threaddm->do_set('username'$username2);
            
//$threaddm->do_set('open', $open);
            
$threaddm->do_set('iconid'$posticons);
            
$threaddm->do_set('allowsmilie'$allowsmilie);
            
$threaddm->do_set('showsignature'$showsignature);
            
$threaddm->do_set('visible'$visible);
            
$threaddm->pre_save();
            
            if(
count($threaddm->errors) < 1)
            {
                
$threadid $threaddm->save();
                unset(
$threaddm);
                
build_thread_counters($threadids);
                
            
build_forum_counters($forumid);    
            }
        }         

        
// Update Post Count For Poster
        
if ($vbulletin->options['ozzmodz_welcome_thread_auto_post_count_posts'])
        {
            
$posts $vbulletin->db->query_first("
                SELECT posts
                 FROM " 
TABLE_PREFIX "user
                  WHERE userid = "
.$vbulletin->options['ozzmodz_welcome_thread_auto_post_userid']."
               "
);
    
             
$newpostcount $posts['posts'] + 1;
    
             
$vbulletin->db->free_result($posts);
    
             
$vbulletin->db->query_write("
                 UPDATE " 
TABLE_PREFIX "user
                 SET posts = "
.$newpostcount."
                  WHERE userid = "
.$vbulletin->options['ozzmodz_welcome_thread_auto_post_userid']."
               "
);
        }

Reply With Quote
  #4  
Old 11-20-2014, 06:55 PM
ETS|LuucEarth ETS|LuucEarth is offline
 
Join Date: Jul 2014
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I found the issue. One of my fellow coders was using $userdata[] in their code globally on a userdata_postsave plugin. This was throwing a fatal error Call to a member function fetch_field() on a non-object I changed my $userdata to $usrdata and the problem went away completely.

However I did notice one other thing in the logs.

I get 10 or so of these

14:49:26 PHP Warning: Illegal offset type in isset or empty in /var/www/dev.elitetestingservices.com/public_html/vb/phrase.php on line 339 error
14:49:26 PHP Warning: Illegal offset type in /var/www/dev.elitetestingservices.com/public_html/vb/phrase.php on line 334

Im calling phrases in part of my code, maybe you can tell me what Ive done wrong

PHP Code:
       $titles=new vB_Phrase ('cprofilefield',$key.'_title');
       
$title=vB_Phrase::fetchPhrase($titles,null); 
The code works and pulls the data properly but I would love to get rid of the warinings
Reply With Quote
  #5  
Old 11-20-2014, 07:13 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not familiar with the vB_Phrase class, but looking at the code, it seems that that warning is happening because you're passing null as the second parameter to fetchPhrase(). You say it works so I guess it's OK to do that, but I don't know what that's supposed to do or what you could do instead.
Reply With Quote
  #6  
Old 11-20-2014, 07:16 PM
ETS|LuucEarth ETS|LuucEarth is offline
 
Join Date: Jul 2014
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

its a parameters for passing {option} type of things to the phrase. However these phrases do not use them. I could try something else in there I guess I added null to get rid of the Missing 2nd argument warnings
Reply With Quote
  #7  
Old 11-20-2014, 07:20 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, now that I think about it a little more, I really was making a guess. It may not be the null. But I suppose it's easy enough to try.
Reply With Quote
  #8  
Old 11-20-2014, 07:34 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh, yeah, I was being an idiot. I'm pretty sure the problem is really that the first argument should be a string but you're passing the vB_Phrase object. It looks llike the parameters should be the phrase group and the phrasekey, which I believe is the phrase name.
Reply With Quote
  #9  
Old 11-20-2014, 08:07 PM
ETS|LuucEarth ETS|LuucEarth is offline
 
Join Date: Jul 2014
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I believe you are correct after I look at the documentation again.

static fetchPhrase (line 333)
Fetches a rendered phrase.

If the phrase is not in the local phrase cache, then the phrasekey cache is loaded and purged.

return: - The translated phrase
access: public
static string fetchPhrase (string $phrasegroup, string $phrasekey, [array $parameters = array()])
string $phrasegroup:
The phrase group where the phrase is located
string $phrasekey:
The phrasekey of the phrase
array $parameters: mixed - Array of parameters to parse into the phrase


That will teach me to code until 4am lol


***EDIT***

PHP Code:
$title=vB_Phrase::fetchPhrase('cprofilefield',$key."_title"NULL); 
That solved the warning Thanks kh99 and Ozzy47 for all the help Product nearly done now!
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 12:25 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05047 seconds
  • Memory Usage 2,364KB
  • Queries Executed 13 (?)
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
  • (5)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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_postinfo_query
  • fetch_postinfo
  • 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