![]() |
vBulletin 5 Request - Require (New Thread), (Edit Thread), (New Post), and (Move Post) Functions VB5.2.3
Require (New Thread), (Edit Thread), (New Post), and (Move Thread) Functions
As it says. I've have an external application from VB4 that used to do the above. However VB5 has changed so much. I haven't been able to figure using external code. Example Function was: Code:
function writepost($userid, $threadid, $postmsg, $title){ function writepost($userid, $threadid, $postmsg, $title) Must return post id function startpost($userid, $forum_id, $postmsg, $title) Must return Thread id function editpost($userid, $postid, $postmsg, $title) Must return Post id function movethread($threadid, $forumid) Must return true false Each one needs to update the forums properly as well ie: Build forum counters or the equivalent in VB5. Startpost was a function that started the initial thread. Not sure if VB5 requires the same. Writepost would write a new post in a current thread. Edit post is where it would edit an existing post, and movethread would move a thread from one forumid to another. I've honestly Tried. I just can't figure out how VB5 does it, and I don't want to give up on VB5. I've looked through createcontent.php and I still can't figure out how its done. Someone please help. |
Starting a thread and posting to a thread is a simple post operation. Here's a sample JSON string that has the minimum requirements for a post or new thread. The CKEditor uses a multi-part binary postfor uploading pics and what not. A lot more code. Writing to a forum nodeid will return a nodeid for the newly created thread. Writing to a thread nodeid will return a nodeid for the new post in that thread. Writing to a Post nodeid will return the nodeid for the newly created comment. Your json string would by submitted via POST (required) to the /create-content/text url. You can use JS, Jquery, curl, or any other http protocol that is http compliant. I've used the Bash shell in Linux using the POST command.
{ "data":{"title":"Sample Title", "securitytoken":"Valid Security Token", "parentid"="Forum or Thread or Post nodeid"}} Moving a thread can be accopmlished with a POST to /ajax/api/node/movePosts. Data required is newtitle="Hello World", to_parent=Forum Nodeid , nodeids[] = 9305 (Array is Required), securitytoken=Valid token. Editing an existing post will be trickier. The post request for editing pulls a ckeditor template. You can make POST nodeid="post-to-be-edited" to /api/node/getNodeContent (permissions required). That will give you a JSON string with all the info about that nodeid including the bbcode held in the rawtext field. You can import that code into your app for editing then save to create-content/Text/. You will need to get the params from the dev environment while saving a edited post. It'll be multipart binary so You'll have to play with it a bit. It's not too difficult. Most if not all of the functions can also be done in php but I figure why bother? The VB5 api has all the checks, security, and verification in place already and puts everything where it;'s supposed to be in the database. Good Luck. |
Replicant,
First let me thank you for responding. I get what your saying but here's the issue that I have. Some of the people don't have the permissions required when these posts are made or edited. They are sent to their command and staff where only they have access to it. But it's an automated post of stuff have done for the day. Sometimes when they redo something. It will go back and edit the post and add to it automatically. Nothing that is in the post is typed by the user. I'm not using ckeditor in any way. Its all an internal script that when someone does a part of a job it writes a new thread once its been marked done. If it was a user doing something with ckeditor I can totally get where your coming from and it would only make sense to do it that way. But its an automated post. I've tried doing it via PHP. I've at least think I figured out the code to do it: Code:
define('VB_ENTRY', 1); |
So this is a guest user post? What is the text input user interface? What are you getting the errors thrown on...editing or posting? Are you using the mapi interface or a web browser interface?
|
No sir. It gets the user info from $vbulletin->userinfo.
The text input is a variable generated. Sample is: Code:
while ($billetRow = $billetResult->fetch_assoc()){ At a specific time, a php script is run at night and it will move the thread to another forum to be audited later. |
Can you go back to vb4?
|
Quote:
|
At Dragonsys. Currently there is no undo for the database. I've seen a couple folks that have managed to convert back but at this point I feel it would be easier to get this working.
Oh oh oh.. As I write this I've gotten a working write a new post in an existing thread in php. So its not seeming so bleak. But I need to figure out how to write a new thread. Now that I have figured this out, I'm pretty sure I can get the rest in time. It's not pretty. But it works. My issue btw was the: vB5_Autoloader::register(dirname(__FILE__)); dirname(__FILE__) grabs your current working folder so I changed this to be the forums and solved the rest of my issues at least for creating a post. I've posted this code so that if someone needed something like I did they can use it. Its not cleaned up, as I'm not sure what needs to stay or go yet. But it works, and should get you where you need to go. Code:
<?PHP |
If you wrote to an existing thread, change the thread nodeid you wrote to to the forum nodeid and it will create a new thread.
|
Replicant. That worked like a charm! This also allows to edit. Its all I need in one function. Pretty amazing.
Thank you for all your help Replicant. In this and the other things you've assisted me with. You are a gentleman and a scholar, and some day, people will sing songs of your glory! You most certainly are appreciated. By me at least. Again. Thank you! --------------- Added [DATE]1471962005[/DATE] at [TIME]1471962005[/TIME] --------------- I've come across the dilemma of no permissions when trying to use this which I was afraid of. Is there a trick to bypass this? Or is it way more in depth. I fear for me, that I'm back at square one. |
I have done something similar to this. I created an API wrapper in the frontend controller. You don't have to include any file at all.
Create a php file named apiwrapper.php in /includes/vb5/frontend/controller directory. The class name suffix has to match the filename. PHP Code:
|
Glenn, Thank you for the assist. This is great if you want to post as someone else. (I will definitely keep this, I'm sure I can use it). What I was trying to do is. Right after the member has been approved, and the save has completed, but before the welcome email has been sent. I needed it to send a post to a forum that is accessible to usergroup 2. Problem is. They are not usergroup 2 yet at that point, even though its saved. However. I was able to take a chunk of your code
Code:
$newsession = new vB_Session_Cli(vB::getDbAssertor(), vB::getDatastore(), vB::getConfig(), $postUserId); This way I have the postid, and I can use it in the welcome email to tell the user to watch the post for questions on their recruitment. No code modified. I wouldn't have been able to do it without your section of code, or the idea to change user sessions. So thank you very much. You and Replicant are a great value to this community. I don't care what they say about you ;) |
Glenn has been my mentor from the beginning. His tips on CSS are what got me started. I'm not a coder, just more of a hacker and I have learned a ton of how to do things in vb5 from Glenn. His examples allowed me to understand what's going on in the back end more so than would have been possible on my own. Some of his posts, like the previous one are very illuminating.
|
Glad to help @Necrophyte. :)
@Replicant, I'm impressed that you learned to code when you are not a coder. :) |
Thanks Glenn. I'm still learning and have a long way to go. If I had to depend on coding skills to eat, I'd be starving :) These little mod projects help a lot with understanding the quirks of PHP. I've done a ton of bash scripting over the last 20 years, but PHP is a whole different animal. At least with a background in bash, I'm able to read the code and figure out what it's doing most of the time. It's the syntax and the array handling that gets me confused sometimes. It's coming right along though.
|
I have to agree. You both have taught me much. My eyes started to glaze over on some of the stuff you guys were talking about. I do Database management, with some php scripts here and there to modify data and manipulate the database here and there. But never to the extend vBulletin is.
I'm sure I'll have many more questions. |
All times are GMT. The time now is 05:49 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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|