Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
2.0k views
in Q2A Core by
How can I disable authors to close or hide their own questions and comments ?
Q2A version: 1.6.2
by
Anyone can help?

1 Answer

+4 votes
by
edited by

Add codes in your theme.php

function q_view_buttons($q_view) {
  if (!empty($q_view['form'])) {
    if(qa_get_logged_in_userid() == $q_view['raw']['userid']) {
      /*
      define('QA_USER_LEVEL_BASIC', 0);
      define('QA_USER_LEVEL_APPROVED', 10);
      define('QA_USER_LEVEL_EXPERT', 20);
      define('QA_USER_LEVEL_EDITOR', 50);
      define('QA_USER_LEVEL_MODERATOR', 80);
      define('QA_USER_LEVEL_ADMIN', 100);
      define('QA_USER_LEVEL_SUPER', 120);
      */
      if(qa_get_logged_in_level() < QA_USER_LEVEL_EXPERT) {
        if(isset($q_view['form']['buttons']['close']))
          unset($q_view['form']['buttons']['close']);
        if(isset($q_view['form']['buttons']['hide']))
          unset($q_view['form']['buttons']['hide']);
      }
    }
  }
  qa_html_theme_base::q_view_buttons($q_view);
}
by
How can you make up to 30 minutes to appear edit button. And then after 30 minutes is not display edit button and hide button?
by
I have wordpress integration. Will this work ?
by
@ Ербол Сери  Below is just hint.

echo '<PRE>';

$created = $q_view['raw']['created'];
echo 'created = '.date("Y/m/d H:i:s", $created)."\n";
echo 'created(<STRONG>+30</STRONG> minutes) = '.date("Y/m/d H:i:s", $created+(30*60))."\n<BR/>";

$updated = $q_view['raw']['updated'];
echo 'updated = '.date("Y/m/d H:i:s", $updated)."\n";
echo 'updated(<STRONG>+30</STRONG> minutes) = '.date("Y/m/d H:i:s", $updated+(30*60))."\n<BR/>";

$now = time();
echo 'now = '.date("Y/m/d H:i:s", $now)."\n";
echo 'now(<STRONG style="color:red">-30</STRONG> minutes) = '.date("Y/m/d H:i:s", $now-(30*60))."\n<BR/>";
echo print_r($q_view,true);

echo '</PRE>';
by
@polle Upper logic does not consider external user. Because integration program (external user inner Q2A) is weak feature that tends to produce bug, I don't like it.
by
@sama55: Could you please tell me which exactly file do you mean by "theme.php"?
I added this code to "qa-theme-base.php" and "qa-theme.php" but nothing changed.
BTW, Does this code work for Q2A 1.6.3 at all?
by
> Does this code work for Q2A 1.6.3 at all?

Yes.

> Could you please tell me which exactly file do you mean by "theme.php"?

If you are using Snow theme, add codes at end (before of last "}" ) of qa-theme/Snow/qa-theme.php. I modified a little codes of christoph.

http://www.question2answer.org/qa/27468

    function q_view_buttons($q_view) {
      if (!empty($q_view['form'])) {
        if(qa_get_logged_in_userid() == $q_view['raw']['userid']) {
          /*
          define('QA_USER_LEVEL_BASIC', 0);
          define('QA_USER_LEVEL_APPROVED', 10);
          define('QA_USER_LEVEL_EXPERT', 20);
          define('QA_USER_LEVEL_EDITOR', 50);
          define('QA_USER_LEVEL_MODERATOR', 80);
          define('QA_USER_LEVEL_ADMIN', 100);
          define('QA_USER_LEVEL_SUPER', 120);
          */
          if(qa_get_logged_in_level() < QA_USER_LEVEL_EXPERT) {
            if(isset($q_view['form']['buttons']['close']))
              unset($q_view['form']['buttons']['close']);
            if(isset($q_view['form']['buttons']['hide']))
              unset($q_view['form']['buttons']['hide']);
          }
        }
      }
      qa_html_theme_base::q_view_buttons($q_view);
    }
    function a_item_buttons($a_item) {
        if (!empty($a_item['form'])) {
            if (qa_get_logged_in_userid() == $a_item['raw']['userid']) {
                /*
                  define('QA_USER_LEVEL_BASIC', 0);
                  define('QA_USER_LEVEL_APPROVED', 10);
                  define('QA_USER_LEVEL_EXPERT', 20);
                  define('QA_USER_LEVEL_EDITOR', 50);
                  define('QA_USER_LEVEL_MODERATOR', 80);
                  define('QA_USER_LEVEL_ADMIN', 100);
                  define('QA_USER_LEVEL_SUPER', 120);
                 */
                if (qa_get_logged_in_level() < QA_USER_LEVEL_EXPERT) {
                    if (isset($a_item['form']['buttons']['hide']))
                        unset($a_item['form']['buttons']['hide']);
                }
            }
        }
        qa_html_theme_base::a_item_buttons($a_item);
    }
    function c_item_buttons($c_item) {
        if (!empty($c_item['form'])) {
            if (qa_get_logged_in_userid() == $c_item['raw']['userid']) {
                /*
                  define('QA_USER_LEVEL_BASIC', 0);
                  define('QA_USER_LEVEL_APPROVED', 10);
                  define('QA_USER_LEVEL_EXPERT', 20);
                  define('QA_USER_LEVEL_EDITOR', 50);
                  define('QA_USER_LEVEL_MODERATOR', 80);
                  define('QA_USER_LEVEL_ADMIN', 100);
                  define('QA_USER_LEVEL_SUPER', 120);
                 */
                if (qa_get_logged_in_level() < QA_USER_LEVEL_EXPERT) {
                    if (isset($c_item['form']['buttons']['hide']))
                        unset($c_item['form']['buttons']['hide']);
                }
            }
        }
        qa_html_theme_base::c_item_buttons($c_item);
    }
...