 |
06-24-2009, 01:54 PM
|
#1 | | vBulletin Owner
Join Date: Apr 2007 Location: Chesapeake, VA
Posts: 135
| Need a little PHP help please Ok, so, still working on the moderator application system, but trying to make the option to create a thread when a new application is submitted.
I currently have this: PHP Code: // Make a new thread require_once(DIR . '/includes/class_dm.php'); require_once(DIR . '/includes/class_dm_threadpost.php');
$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$forumid = intval($vbulletin->options['usml_modapp_forumid']); $foruminfo = verify_id('forum', $forumid, 0, 1); $userid = fetch_userinfo($vbulletin->GPC['username']); $userid = intval($userid['userid']);
$iconid = 1; $visible = 1; $allowsmilie = 1;
$title = 'Mod Application: ' . $vbulletin->GPC['username']; $pagetext = $message;
$threaddm->set('forumid', $forumid); $threaddm->set('userid', $userid); $threaddm->set('pagetext', $pagetext); $threaddm->set('title', $title); $threaddm->set('allowsmilie', $allowsmilie); $threaddm->set('visible', $visible); $threaddm->set_info('forum', $foruminfo); $threaddm->pre_save(); $threaddm->save();
But throws an after submitting saying: Code: Fatal error:
* No Users Matched Your Query
* You did not specify a username for your post.
Unable to proceed with save while $errors array is not empty in class vB_DataManager_Thread_FirstPost in [path]/includes/class_dm.php on line 810
#0 vb_error_handler(256,
* No Users Matched Your Query
* You did not specify a username for your post
What am I doing wrong? Do I need to add a query? If so, how do I do that? This is my first time making a mod that creates a thread automatically and I've never really messed with the database much at all.
So any help is greatly appreciated!
Thanks in advance! |
| |
06-25-2009, 09:22 AM
|
#2 | | vBulletin Owner
Join Date: Apr 2007 Location: Chesapeake, VA
Posts: 135
| Re: Need a little PHP help please Ok, this is the closest I got to it working but I got this error: PHP Code: Fatal error:
* That username is already in use or does not meet the administrator's standards. If you are HMBeaty and you have forgotten your password, click here.
Unable to proceed with save while $errors array is not empty in class vB_DataManager_Thread_FirstPost in [path]/includes/class_dm.php on line 810 #0 vb_error_handler(256,
* That username is already in use or does not meet the administrator's standards. If you are HMBeaty and you have forgotten your password, click here.
And this is what I have in my php file: PHP Code: <?php /*======================================================================*\ || #################################################################### || || # U.S. Military Life Moderator Application Package v1.1.0 # || || # ---------------------------------------------------------------- # || || # Copyright © U.S. Military Life 2009 # || || # This file may not be redistributed in whole or significant part. # || || # ---------------------------------------------------------------- # || || # http://www.USMilitaryLife.com # || || #################################################################### || \*======================================================================*/
// ####################### SET PHP ENVIRONMENT ########################### error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS ####################### define('NO_REGISTER_GLOBALS', 1); define('THIS_SCRIPT', 'modapp'); // change this depending on your filename
// ################### PRE-CACHE TEMPLATES AND DATA ###################### // get special phrase groups $phrasegroups = array('global');
// get special data templates from the datastore $specialtemplates = array();
// pre-cache templates used by all actions $globaltemplates = array( 'moderator_app' );
// pre-cache templates used by specific actions $actiontemplates = array();
// ######################### REQUIRE BACK-END ############################ require_once('./global.php');
// ####################################################################### // ######################## START MAIN SCRIPT ############################ // #######################################################################
// ####################################################################### // Some more definitions $imp_vars = array( 'do' => '' );
$pages = array( 'main', 'send' ); $addresses = explode(",", $vbulletin->options['usml_mod_application_options_emails']);
$imp_vars['do'] = $_REQUEST['do'];
if (!(in_array($imp_vars['do'], $pages))) { $imp_vars['do'] = 'main'; }
// Check to see if applications are turned on/off if ($vbulletin->options['usml_mod_application_options_on'] == 0) { print_no_permission(); } // Check usergroup permissions if (is_member_of($vbulletin->userinfo, explode(',',$vbulletin->options['usml_modapp_ugperms']))) { print_no_permission(); } // Check users post count permissions if ($vbulletin->userinfo[posts] < $vbulletin->options['usml_modapp_pcperms']) { print_no_permission(); }
// Set-up the navbar $navbits = array(); $navbits[] = 'Moderator Application';
// End boring stuff // #######################################################################
if ($imp_vars['do'] == 'main') { $navbits = construct_navbits($navbits); eval('$navbar = "' . fetch_template('navbar') . '";'); eval('print_output("' . fetch_template('moderator_app') . '");'); }
if ($imp_vars['do'] == 'send') { $vbulletin->input->clean_array_gpc('p', array( 'position_applying' => TYPE_NOHTML, 'username' => TYPE_NOHTML, 'additional_usernames' => TYPE_NOHTML, 'first_name' => TYPE_NOHTML, 'last_name' => TYPE_NOHTML, 'birth_month' => TYPE_NOHTML, 'birth_day' => TYPE_NOHTML, 'birth_year' => TYPE_NOHTML, 'city' => TYPE_NOHTML, 'state' => TYPE_NOHTML, 'why_help' => TYPE_NOHTML, 'skills' => TYPE_NOHTML, 'ever_used_backend' => TYPE_NOHTML, 'know_options' => TYPE_NOHTML, 'moderate_others' => TYPE_NOHTML, 'moderated_forums' => TYPE_NOHTML, 'how_long' => TYPE_NOHTML, 'ever_resigned' => TYPE_NOHTML, 'reason_resigned' => TYPE_NOHTML, 'still_active' => TYPE_NOHTML, 'comments' => TYPE_NOHTML, 'email' => TYPE_NOHTML, 'tel_1' => TYPE_NOHTML ));
// Check all the variables if ($vbulletin->GPC['position_applying'] == '') { $errors[] = 'You did not specify which position you are applying for.'; }
// Check all the variables if ($vbulletin->GPC['username'] == '') { $errors[] = 'You did not specify your username.'; }
// Check all the variables if ($vbulletin->GPC['first_name'] == '') { $errors[] = 'You did not specify your first name.'; }
// Check all the variables if ($vbulletin->GPC['last_name'] == '') { $errors[] = 'You did not specify your last name.'; }
// Check all the variables if ($vbulletin->GPC['birth_month'] == '') { $errors[] = 'You did not specify your birth month.'; } // Check all the variables if ($vbulletin->GPC['birth_day'] == '') { $errors[] = 'You did not specify your birth day.'; } // Check all the variables if ($vbulletin->GPC['birth_year'] == '') { $errors[] = 'You did not specify your birth year.'; }
// Check all the variables if ($vbulletin->GPC['city'] == '') { $errors[] = 'You did not specify your city.'; }
// Check all the variables if ($vbulletin->GPC['state'] == '') { $errors[] = 'You did not specify your state.'; }
// Check all the variables if ($vbulletin->GPC['why_help'] == '') { $errors[] = 'You did not specify why you want to help this forum.'; }
// Check all the variables if ($vbulletin->GPC['skills'] == '') { $errors[] = 'You did not specify what skills you can bring to this forum.'; } // Check all the variables if ($vbulletin->GPC['ever_used_backend'] == '') { $errors[] = 'You did not specify if you ever used the backend of a vBulletin forum.'; } // Check all the variables if ($vbulletin->GPC['know_options'] == '') { $errors[] = 'You did not specify if you know any of the options.'; } // Check all the variables if ($vbulletin->GPC['moderate_others'] == '') { $errors[] = 'You did not specify if you moderate on other forums.'; } // Check all the variables if ($vbulletin->GPC['moderate_others'] == 'Yes' AND $vbulletin->GPC['moderated_forums'] == '') { $errors[] = 'You did not specify what forum(s) you moderate.'; } // Check all the variables if ($vbulletin->GPC['moderate_others'] == 'Yes' AND $vbulletin->GPC['how_long'] == '') { $errors[] = 'You did not specify how long you have been moderating other forums.'; } // Check all the variables if ($vbulletin->GPC['ever_resigned'] == '') { $errors[] = 'You did not specify if you have ever resigned from a staff position.'; } // Check all the variables if ($vbulletin->GPC['ever_resigned'] == 'Yes' AND $vbulletin->GPC['reason_resigned'] == '') { $errors[] = 'You did not include a reason wny you resigned from a staff position.'; } // Check all the variables if ($vbulletin->GPC['still_active'] == '') { $errors[] = 'You did not specify if will still be an active member of our community if you do not get the position you have applied for.'; } // Check all the variables if ($vbulletin->GPC['email'] == '' AND $vbulletin->GPC['tel_1'] == '') { $errors[] = 'You did not specify an email address or a telephone number, you must specify at least one of the two.'; }
// Print the errors if (count($errors) > 0) { foreach ($errors AS $error) { $new_errors .= $error . "<br />\n"; } $errors = "The following errors were found; <br />"; $errors .= $new_errors; $submit = false; } else { $submit = true; } if ($submit) { if ($vbulletin->GPC['email']) { $contact = "E-mail: " . $vbulletin->GPC['email'] . ". "; } if ($vbulletin->GPC['tel_1']) { $contact .= "Telephone Number: " . $vbulletin->GPC['tel_1'] . ". "; }
// Build Emails $subject = "Moderator Application"; $message = "Hello, A new moderator application has just been submitted!
Position applying for: " . $vbulletin->GPC['position_applying'] . ". Username: " . $vbulletin->GPC['username'] . ". Additional Usernames: " . $vbulletin->GPC['additional_usernames'] . ". First Name: " . $vbulletin->GPC['first_name'] . ". Last Name: " . $vbulletin->GPC['last_name'] . ". Birthday: " . $vbulletin->GPC['birth_month'] . "/" . $vbulletin->GPC['birth_day'] . "/" . $vbulletin->GPC['birth_year'] . ". Location: " . $vbulletin->GPC['city'] . ", " . $vbulletin->GPC['state'] . ". Why do you want to help this forum: " . $vbulletin->GPC['why_help'] . ".
What skills can you bring to this forum: " . $vbulletin->GPC['skills'] . ".
Have you ever used the backend of a vBulletin forum: " . $vbulletin->GPC['ever_used_backend'] . ". Do you know any of the options: " . $vbulletin->GPC['know_options'] . ". Do you moderate on other forums: " . $vbulletin->GPC['moderate_others'] . ". If yes, what other forum(s) do you moderate: " . $vbulletin->GPC['moderated_forums'] . ".
How long have you been moderating other forums: " . $vbulletin->GPC['how_long'] . ". Have you ever resigned from a staff position: " . $vbulletin->GPC['ever_resigned'] . ". If yes, please include details/reasons why: " . $vbulletin->GPC['reason_resigned'] . "
If you do not get the position you have applied for, will you still be an active member of our community?: " . $vbulletin->GPC['still_active'] . ". Enter any additional information: " . $vbulletin->GPC['comments'] . "
" . $contact . " IP Address: " . IPADDRESS . " Host: " . @gethostbyaddr(IPADDRESS) . "
Regards, Your site."; // Send Emails if (!class_exists('vB_Mail')) { require_once(DIR . '/includes/class_mail.php'); } foreach ($addresses AS $address) { if ($vbulletin->options['use_smtp']) { $mail =& new vB_SmtpMail($vbulletin); } else { $mail =& new vB_Mail($vbulletin); } $mail->start($address, $subject, $message, $vbulletin->options['webmasteremail']); $mail->send(); unset($mail); }
// Make a new thread require_once(DIR . '/includes/class_dm.php'); require_once(DIR . '/includes/class_dm_threadpost.php');
$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$forumid = intval($vbulletin->options['usml_modapp_forumid']); $foruminfo = verify_id('forum', $forumid, 0, 1); $userid = $vbulletin->userinfo['userid'];
$iconid = 1; $visible = 1; $allowsmilie = 1;
$title = 'Mod Application: ' . $vbulletin->GPC['username']; $pagetext = $message;
$threaddm->set('username', $vbulletin->GPC['username']); $threaddm->set('forumid', $forumid); $threaddm->set('userid', $userid); $threaddm->set('pagetext', $pagetext); $threaddm->set('title', $title); $threaddm->set('allowsmilie', $allowsmilie); $threaddm->set('visible', $visible); $threaddm->set_info('forum', $foruminfo); $threaddm->pre_save(); $threaddm->save();
$newtext = "Thank you for enquiring, your request will be processed and we will respond to you shortly."; $navbits = construct_navbits($navbits); eval('$navbar = "' . fetch_template('navbar') . '";'); eval('print_output("' . fetch_template('moderator_app') . '");'); } else { $imp_vars['do'] = 'errors'; $vbgpc =& $vbulletin->GPC; $navbits = construct_navbits($navbits); eval('$navbar = "' . fetch_template('navbar') . '";'); eval('print_output("' . fetch_template('moderator_app') . '");'); } }
// ####################################################################### // ######################### END MAIN SCRIPT ############################# // ####################################################################### ?> Can anyone PLEASE tell me what I need to add/change? I'm about ready to pull my hair out on this one |
| |
06-25-2009, 09:31 AM
|
#3 | | Supporters vBulletin Owner
Join Date: Dec 2006 Location: Delaware
Posts: 4,035
| Re: Need a little PHP help please wish i could help your redline but that is greek to me, im sure someone here can though |
| |
06-25-2009, 10:13 AM
|
#4 | | vBulletin Owner
Join Date: Apr 2007 Location: Chesapeake, VA
Posts: 135
| Re: Need a little PHP help please Ok, thanks to the help from Idan, fully tested and working using this code: PHP Code: // Make a new thread require_once(DIR . '/includes/functions_newpost.php');
$forumid = intval($vbulletin->options['usml_modapp_forumid']); $user_id = $vbulletin->userinfo['userid']; $username = $vbulletin->userinfo['username'];
$target_foruminfo = fetch_foruminfo($forumid); $newpost = array( 'userid' => $user_id, 'username' => $username, 'message' => $message, 'title' => 'Mod Application: ' . $vbulletin->GPC['username'], 'poststarttime' => time(), 'emailupdate' => 0 );
build_new_post('thread', $target_foruminfo, array(), array(), $newpost, $errors);
// Check if any errors during post if (sizeof($errors) > 0) { // Post of new thread failed ! $error_info = construct_errors($errors); //echo $error_info; // do anything you want here - likely to redirect ! // ... }
// Fix forums counters build_forum_counters($forumid);
|
| | |