Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 03-01-2011, 08:34 PM
kvnband kvnband is offline
 
Join Date: Feb 2004
Location: AR
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default New to VB programming, but not PHP. Simple plugin question

OK - I am new to the world of programming products and plugins for VB, but not to PHP development in general. For my first project, I have created 5 custom profile fields in the admincp. We have a large, established user-base, and I need to make sure that these 5 fields are filled out, for tax purposes (We are a non-profit org).

So, how do I proceed? I basically just need to know how I check the logged-in user's custom profile fields at the start of each page load. I assume writing a small plugin is the way forward here, but aside from that, I'm completely clueless.

Any help?

Thanks!
Reply With Quote
  #2  
Old 03-01-2011, 09:08 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

When you create (or edit) the profile field, there is the option to make the Field Required. If you have it set to show on the Edit Profile page, then the user will get told they need to edit their profile before continuing to do anything on the site. (Admins are exempt from this, I believe.)
Reply With Quote
  #3  
Old 03-01-2011, 09:26 PM
kvnband kvnband is offline
 
Join Date: Feb 2004
Location: AR
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's what I thought, Lynne. But since implementing the fields, we have had about 10 users sign on and post in the forum. None of them have updated those fields. The fields are set to be required at registration and profile editing, and are set to be editable by the user.

Since nobody updated their information, I assumed it wasn't a built-in feature and that I would need to write a little plugin to force them to.

--------------- Added [DATE]1299022976[/DATE] at [TIME]1299022976[/TIME] ---------------

So I'm just an idiot. I didn't notice that one of the options for "required" was "Yes, Always". Set that, and it appears to be working.

Now - Where can I go to learn about VB programming in general? I need to come up with an election voting module here in the next 3 months. I could do it in a few hours in pure PHP but I'm clueless where to even start with making a VB product....
Reply With Quote
  #4  
Old 03-01-2011, 09:47 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do not set it to Field Required "Yes, at registration and profile updating", set it to "Yes, always". And, what did you set for Which page display this option?
Reply With Quote
  #5  
Old 03-01-2011, 10:24 PM
kvnband kvnband is offline
 
Join Date: Feb 2004
Location: AR
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lynne - I edited my post right before you replied...Your solution was spot on though.

Now - Where can I go to learn about VB programming in general? I need to come up with an election voting module here in the next 3 months. I could do it in a few hours in pure PHP but I'm clueless where to even start with making a VB product....
Reply With Quote
  #6  
Old 03-02-2011, 03:27 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Glad you got that working.

The way I learned how to code vb was by first downloading simply mods and seeing how they were done. Then I started wanting to do things my self and so I would download mods that kinda did what I wanted and then I would modify them to do what I wanted. So, I kinda learned how things worked by doing it that way.
Reply With Quote
  #7  
Old 03-02-2011, 11:43 AM
kvnband kvnband is offline
 
Join Date: Feb 2004
Location: AR
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think I'm going to do just that, but keep it basic at first. Create my new bitfield permissions (Who can create elections, who can vote in elections, who can see election results) and then just use the forum front-end for the administration of things at first. That way I can just have plain PHP files out there that only tie in to VB when checking for permissions. Seems like a decent way to get started....

And yes - I will definitely need to check out other products for inspiration. I think I can figure things out.

Thanks for your help.

--------------- Added [DATE]1299097555[/DATE] at [TIME]1299097555[/TIME] ---------------

Soooo I need help again. I created my product, set up my bitfields, and set up my permissions. But I absolutely cannot figure out how to check those permissions in my script. I see that I'm obviously not accessing the correct values, but I don't know where else to check. I am trying to see if the currently logged in user has permission to vote or not. This is just real basic while I'm trying to acclimate myself to the system. Can you help me / point me in the right direction?

PHP Code:
<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################

define('THIS_SCRIPT''voting_booth');
define('CSRF_PROTECTION'true);  
// change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array('tsgvotingbooth',
);

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
// chdir ('/path/to/your/forums');
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

$navbits construct_navbits(array('' => 'Voting Booth'));
$navbar render_navbar_template($navbits);

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle 'Voting Booth';

// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######

if(!$vbulletin->bf_ugp['tsgvb_permissions']['canvote']) {
    
print_no_permission();
}

$templater vB_Template::create('tsgvotingbooth');
$templater->register_page_templates();
$templater->register('navbar'$navbar);
$templater->register('pagetitle'$pagetitle);
print_output($templater->render());

?>
Reply With Quote
  #8  
Old 03-02-2011, 08:02 PM
wpeloquin wpeloquin is offline
 
Join Date: May 2006
Location: Behind you...
Posts: 143
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you set up a Setting Group for the plugin in the AdminCP > Options, you would use something like
Code:
if (($vbulletin->options['customplugin_enable'] == 1) AND is_member_of($vbulletin->userinfo, explode(',', $vbulletin->options['customplugin_votegroups'])))
customplugin_enable would be a yesno field (turn on/off the plugin) and the customplugin_votegroups would be a comma separated list

i'd recommend putting the typical 5, 6, 7 as default for the _votegroups, blank Option Code, and add something like (comma separated ID list) in the description
Reply With Quote
  #9  
Old 03-02-2011, 08:17 PM
kvnband kvnband is offline
 
Join Date: Feb 2004
Location: AR
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for your response. I actually came with that method on my own on another product I was tinkering with, but I don't want to go that route with this product. With this product, I want to control the usergroup permissions in the usergroup editor. So I've successfully set up the /admincp stuff, but I just can't figure out how to check if one of the current member's usergroups 'canvote'.

I do appreciate your help. Hopefully you have an idea on how to accomplish it this alternative way...
Reply With Quote
  #10  
Old 03-02-2011, 08:53 PM
wpeloquin wpeloquin is offline
 
Join Date: May 2006
Location: Behind you...
Posts: 143
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I assume you mean add a custom section in the AdminCP > Usergroups > Usergroup Manager > Edit Usergroup, something like how it has Forum Viewing Permissions, Forum Searching Permissions, etc?

Code:
Vote Settings
Can members use the Vote System? yes/no Option 2? yes/no Option 3? yes/no
if so, i am sure there is a way to do it, as i've seen other plugins do it. However, i cannot help with that . Hopefully this helps some though, if anyone else does know!
Reply With Quote
Reply

Thread Tools
Display Modes

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 11:42 PM.


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.04588 seconds
  • Memory Usage 2,264KB
  • 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
  • (2)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete