Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
1.8k views
in Q2A Core by
SOS

2 Answers

0 votes
by

The question is a bit unclear but it should be something like: "Can pending approval posts be edited before approving them?". The answer is: they can not. You have to first approve them and then edit then.

Partially discussed here: https://github.com/q2a/question2answer/issues/123

by
Regarding the original question: I agree it's a good idea to be able to edit posts before approving them, so it's hopefully something that will be added in future.

Regarding function overrides: pupi1985 is correct that you should call through to the parent function instead of copy-pasting an entire function (especially such a huge function like qa_page_q_post_rules!) See http://www.question2answer.org/overrides.php

In almost every single circumstance you should be calling through to the base/parent function, it's almost never necessary to completely replace a function. As pupi1985 says you can call through to the base function then edit one of the variables and return as normal.

As an example, I recently noticed an instance in the new Snow theme where an overridden function could be replaced by one small change and a call-through to the parent function: https://github.com/q2a/question2answer/commit/b4844889ed342ccb0e1f84f0803b7ddc4a6d5e42
by
Here's an example for your plugin:

function qa_page_q_post_rules($post, $parentpost=null, $siblingposts=null, $childposts=null)
{
    $rules = qa_page_q_post_rules_base($post, $parentpost, $siblingposts, $childposts);

    $rules['editbutton'] = (!$post['hidden']) && (!$rules['closed']) &&
        ($rules['isbyuser'] || (($permiterror_edit!='level') && ($permiterror_edit!='approve')));

    return $rules;
}
by
I agree with both of you and @scott, thanks for the snippet.

I admit my mistake, I have done junk code in hurry. This is just because, I wanted to make something quick in few hours. So quickly dig and created. But no excuse, mistake is mistake and again admit.

However, regarding overriding function. What I believe is once system allow to do  things than there is nothing wrong to do, if you do it in correct way (I did a mistake) and we should not bound Devs to use it.

For example WordPress ( I use always WP as an reference just because most of the people aware of it, not comparing Q2A to WP)

It has great system to override function using add_action() and add_filter() which allows to override core function within the limits so use won't be able to override entire function but just can manipulate the result. But what if they say to Developers, hey you should not override the core function!

Uhh! now in this case, there will be a big question arise on the system itself. Why than you add such hook where use can override??? So, here in Q2A where not all functions are allowed to override but some of them. This means, Devs (Gideo and all contributors) know the risk or I would say the possible drawback instead.

Since long I am keep commenting on function overriding issue. Even the theme methods also creating many issues when multiple plugins/themes override the same method.

Please keep in mind that above words is not to save myself from the mistake I did in hurry, ( I have already admin ) but to aware once again to all of contributors (including me) to make a system like add_action() where Devs can override in certain limits and not entire core.

Out of the topic: I am still looking for best theme engine so we can rid off all inline HTML. I can work on this part but the time is the issue.

I will fix this plugin as per scott's snippet.

I thankful and appreciate to pupi and scott to aware me for my mistake. Also gurjyot to notify me for this post otherwise I would miss it due to hell lot of work.
by
The add_action and add_filter methods in WP are almost exactly like event and filter plugins in Q2A. I suppose instead of overriding an entire function, those functions could have 'hooks' similar to event plugins.

The reason for allowing entire functions to be overridden is because in some cases that is what you want to do. Sometimes you want to do something completely different that you can't do by just modifying some variables.

But still for most cases you only want to change one thing in a function and leave the rest, that's exactly why you should call through to the base functions. The problems you mention about multiple plugins/themes overriding the same method *shouldn't* happen, because those overrides should change only what they need to change.
0 votes
by

http://store.q2amarket.com/q2a-free-plugins/edit-and-moderate

If I use this plugin, how do I add a button to change the admin panel ...
 
Now it's like this:
 
1. Click on the question
 
2. edit
 
3. To approve.
 
 
 
must be in the admin panel - moderated
 
button
 
approve --- refuse ---- edit.
 
 
 
on the basis of the plugin
...