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

First of all sorry for my bad english..

i dont want my user can edit their questions and answers.. Only permissions is they can hide them.

Then i add a code at questions-view.php

At 1.6.3 version i havent got any error. But when i upgrade 1.7 i have too much error.. ( its working like before.. but now i have too much error at this time )

Thats my code change 

Original code is ;

---------------------------------------------------

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

        $rules['retagcatbutton']=($post['basetype']=='Q') && (qa_using_tags() || qa_using_categories()) &&
            (!$post['hidden']) && ($rules['isbyuser'] || (($permiterror_retagcat!='level') && ($permiterror_retagcat!='approve')) );
        $rules['retagcatable']=$rules['retagcatbutton'] && ($rules['isbyuser'] || !$permiterror_retagcat);

        if ($rules['editbutton'] && $rules['retagcatbutton']) { // only show one button since they lead to the same form
            if ($rules['retagcatable'] && !$rules['editable'])
                $rules['editbutton']=false; // if we can do this without getting an error, show that as the title
            else
                $rules['retagcatbutton']=false;
        }

---------------------------------------------------

My edits ;

---------------------------------------------------

$level=qa_get_logged_in_level(); 
if ($level>=QA_USER_LEVEL_ADMIN) { 

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

        $rules['retagcatbutton']=($post['basetype']=='Q') && (qa_using_tags() || qa_using_categories()) &&
            (!$post['hidden']) && ($rules['isbyuser'] || (($permiterror_retagcat!='level') && ($permiterror_retagcat!='approve')) );
        $rules['retagcatable']=$rules['retagcatbutton'] && ($rules['isbyuser'] || !$permiterror_retagcat);

        if ($rules['editbutton'] && $rules['retagcatbutton']) { // only show one button since they lead to the same form
            if ($rules['retagcatable'] && !$rules['editable'])
                $rules['editbutton']=false; // if we can do this without getting an error, show that as the title
            else
                $rules['retagcatbutton']=false;
        }
}

--------------------------------------------------

Then in my server error log file always write this ;

Undefined index: closeable in .....public_html/qa-include/pages/question-view.php on line 283
[17-Jan-2015 02:29:04 Europe/Istanbul] PHP Notice:  Undefined index: reopenable in ..../public_html/qa-include/pages/question-view.php on line 290
[17-Jan-2015 02:29:04 Europe/Istanbul] PHP Notice:  Undefined index: editbutton in ..../public_html/qa-include/pages/question-view.php on line 451
[17-Jan-2015 02:29:05 Europe/Istanbul] PHP Notice:  Undefined index: editbutton in .../public_html/qa-include/pages/question-view.php on line 451
[17-Jan-2015 02:29:05 Europe/Istanbul] PHP Notice:  Undefined index: editbutton in .../public_html/qa-include/pages/question-view.php on line 451
[17-Jan-2015 02:29:05 Europe/Istanbul] PHP Notice:  Undefined index: editbutton in .../public_html/qa-include/pages/question-view.php on line 451
[17-Jan-2015 02:30:49 Europe/Istanbul] PHP Notice:  Undefined index: editbutton in .../public_html/qa-include/pages/question-view.php on line 243
[17-Jan-2015 02:30:49 Europe/Istanbul] PHP Notice:  Undefined index: retagcatbutton in .../public_html/qa-include/pages/question-view.php on line 252
[17-Jan-2015 02:30:49 Europe/Istanbul] PHP Notice:  Undefined index: closeable in .../public_html/qa-include/pages/question-view.php on line 283
[17-Jan-2015 02:30:49 Europe/Istanbul] PHP Notice:  Undefined index: reopenable in .../public_html/qa-include/pages/question-view.php on line 290
[17-Jan-2015 02:30:52 Europe/Istanbul] PHP Notice:  Undefined index: editbutton in .../public_html/qa-include/pages/question-view.php on line 243
[17-Jan-2015 02:30:52 Europe/Istanbul] PHP Notice:  Undefined index: retagcatbutton in .../public_html/qa-include/pages/question-view.php on line 252
[17-Jan-2015 02:30:52 Europe/Istanbul] PHP Notice:  Undefined index: closeable in .../public_html/qa-include/pages/question-view.php on line 283
[17-Jan-2015 02:30:52 Europe/Istanbul] PHP Notice:  Undefined index: reopenable in .../public_html/qa-include/pages/question-view.php on line 290
[17-Jan-2015 02:30:52 Europe/Istanbul] PHP Notice:  Undefined index: editbutton in .../public_html/qa-include/pages/question-view.php on line 451
[17-Jan-2015 02:30:52 Europe/Istanbul] PHP Notice:  Undefined index: editbutton in .../public_html/qa-include/pages/question-view.php on line 451
[17-Jan-2015 02:31:07 Europe/Istanbul] PHP Notice:  Undefined index: editbutton in .../public_html/qa-include/pages/question-view.php on line 451
[17-Jan-2015 02:31:27 Europe/Istanbul] PHP Notice:  Undefined index: editbutton in .../public_html/qa-include/pages/question-view.php on line 243
[17-Jan-2015 02:31:27 Europe/Istanbul] PHP Notice:  Undefined index: retagcatbutton in .../public_html/qa-include/pages/question-view.php on line 252

Please help me whats the problem ?

 

Q2A version: 1.7

2 Answers

0 votes
by
edited by

Not sure exactly why it would work in 1.6.3, but the problem is that code defines some variables only for admin then you try to use those variables outside the clause (i.e. for all users).

Probably the best solution would be to leave that code as it is then put the admin clause underneath and set everything to false.

$level = qa_get_logged_in_level();
if ($level < QA_USER_LEVEL_ADMIN) {
    $rules['editbutton'] = false;
    $rules['editable'] = false;
    // and so on
}

by
moved by
Thx for your help firstly..

Nope.. i have the same errors..

if i cant solve this problem i will turn 1.6.3..
0 votes
by

I find this a bit awkward. This is because, for instance, $rules['closeable'] is not wrapped in your IF statement (according to the code you've pasted). Maybe you've added more rules inside the IF statement than you think.

Anyway, if the changes to the logic you've implemented are working fine for you and you want to keep them, I mean, you just want to hide the notice, then probably you could just add an @ in the lines that are bringing you trouble. EG:

If this is the 'closeable' that is giving you trouble:

if ($question['closeable'])
    $buttons['close']=array(
        'tags' => 'name="q_doclose"',
        'label' => qa_lang_html('question/close_button'),
        'popup' => qa_lang_html('question/close_q_popup'),
    );

Then replace the IF statement this way:

if (@$question['closeable'])

This will hide the notice but keep the logic. Bear in mind that if you also have ERRORs instead of NOTICEs then you should consider removing those changes you've done and use the "official" Q2A release.

...