Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
689 views
in Q2A Core by
edited by

I am migrating posts from one installation to another and have heavily rewritten the network plugin of Noahy for this.

Now I need to call the qa_report_event('q_post', ...) on the target forum so that the question appears in the famous liveticker that all my users use.

However, it looks quite complicated in the core: 

qa_report_event('q_post', $oldquestion['userid'], $oldquestion['handle'], $oldquestion['cookieid'], $eventparams + array(

'notify' => isset($oldquestion['notify']),

'email' => qa_email_validate($oldquestion['notify']) ? $oldquestion['notify'] : null,

'delayed' => $oldquestion['created'],

));

How to create a simple q_post event? I dont need the notify / email / delayed options etc.

I don't understand the $oldquestion part, by the way.

---

The function says:

function qa_report_event($event, $userid, $handle, $cookieid, $params = array())

Thus I would just use:

qa_report_event('q_post', $userid, $handle, $cookieid, $params)

where $params must include the postid of the question, `postid=1159 parentid= parent= title=The question title is `

Q2A version: 1.8.0

1 Answer

+1 vote
by

You're looking at the wrong method. You're checking the q_post that gets fired when a question is approved. That's why it references the old question (which would be the one that as pending moderation).

The q_post fired when creating a post should be easier to understand: https://github.com/q2a/question2answer/blob/33bd9dcbcb84643c6cda79e6a6b3b28ce99ee7eb/qa-include/app/post-create.php#L94

How much you can remove of it depends on all the event listeners your plugins and the core has. Take into account there are event modules in qa-include/plugins that listen for q_post events.

Obviously, you can always try to move the data itself and avoid having to recreate it :)

by
I cannot move the data because the migration plugin "recreates" all posts. So copying the eventlog entry to the other eventlog entry would reference the wrong postids.

The "q_post" should in my decent opinion always be fired, or there should be an additional event, e.g. "q_post_in" - in case the q_queue is used.
by
Probably I am going to create the q_post event by myself then...

Those fields are easy to set up:
- datetime
- ipaddress
- userid
- handle
- cookieid
- event

The field params is the challenging one, example entry: "postid=1919    parentid=    parent=    title=My Question Title    content=<p>Hey there</p><p>Can somebody help...    format=html    text=Hey there Can somebody help ... tags=testtag1,testtag2...    categoryid=    extra=    name=    notify=1    email="

But I also think that the params are actually rarely (or not) used. I know from my liveticker plugin that i am only reading the postid from the params.
by
Don't forget to check the events in qa-include/plugins and what THEY require.

Not sure what the "migration plugin" is. However, you can load the data keeping the IDs and that should do it
...