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

After about 6 months of using question2answer I found the time to create a list of all hacks I had to do to get q2a doing what I wanted :)

You may be interested in:

My List of Core Hacks

# qa-app-options.php
line 536:
'updateview' => false, // changed: from true to false, do not show update notice in posting (e.g. "edit by")

# qa-db-selects.php
// do not show closed question in unanswered list - no selected answer
line 339: $bysql='selchildid IS NULL AND closedbyid IS NULL'; // old: $bysql='selchildid IS NULL';
// do not show closed question in unanswered list - no upvoted answer
line 343: $bysql='amaxvote=0 AND closedbyid IS NULL'; // old: $bysql='amaxvote=0';
// do not show closed question in unanswered list
line 347: $bysql='acount=0 AND closedbyid IS NULL'; // old: $bysql='acount=0';

# qa-page-account.php
// prevent that users can change their username!
line 71:  $inemail=$useraccount['email']; // old: $inemail=qa_post_text('email');
line 213: 'type' => 'static', // old: $changehandle ? 'text' : 'static',
line 222: 'type' => 'static', // old: $changehandle ? 'text' : 'static',
→ updated hack! http://www.question2answer.org/qa/28302/

# qa-page-admin-default.php
line 908-910:
$neatoptions[$rawoption]=
    /*commented out: '<IFRAME SRC="'.qa_path_html('url/test/'.QA_URL_TEST_STRING, array('dummy' => '', 'param' => QA_URL_TEST_STRING), null, $rawoption).'" WIDTH="20" HEIGHT="16" STYLE="vertical-align:middle; border:0" SCROLLING="no" FRAMEBORDER="0"></IFRAME>&nbsp;'.*/
    '<SMALL>'. //...


# qa-page-question-view.php
line 174 (added code):
/* START added */
    // users are never allowed to hide posts
    $rules['hideable'] = false;
    /* users are not allowed to edit posts after 10 min */
    $timestamp = time(); // time now
    // 10 min time frame to edit
    $rules['editable'] = $rules['editbutton'] = $rules['isbyuser'] && ($timestamp - $post['created'] < 600);
    // admin has all rights
    $level=qa_get_logged_in_level();
    if ($level>=QA_USER_LEVEL_ADMIN) {
        $rules['editable'] = $rules['editbutton'] = $rules['hideable'] = true;
    }
    // only admin can close questions (and check if question is already closed)
    $rules['closeable'] = ($level>=QA_USER_LEVEL_ADMIN) && (!$rules['closed']);
/* END added */

# qa-page-user.php
line 360-368:
// disabled, do not show special rights!
if (count($showpermits))
        $qa_content['form_profile']['fields']['permits']=array(
            'type' => 'static',
            'label' => qa_lang_html('profile/extra_privileges'),
            'value' => qa_html(implode("\n", $showpermits), true),
            'rows' => count($showpermits),
        );
*/

line 635:
// removed comma in the end
$votegavevalue=(($upvotes==1) ? qa_lang_html_sub('profile/1_up_vote', $innervalue, '1') : qa_lang_html_sub('profile/x_up_votes', $innervalue)).'';

line 637:
/*
// disabled minus points
$downvotes=@$userpoints['qdownvotes']+@$userpoints['adownvotes'];
$innervalue='<SPAN CLASS="qa-uf-user-downvotes">'.number_format($downvotes).'</SPAN>';
$votegavevalue.=($downvotes==1) ? qa_lang_html_sub('profile/1_down_vote', $innervalue, '1') : qa_lang_html_sub('profile/x_down_votes', $innervalue);
*/

line 648 (ca.):
// removed comma in the end
$votegotvalue=((@$userpoints['upvoteds']==1) ? qa_lang_html_sub('profile/1_up_vote', $innervalue, '1')
    : qa_lang_html_sub('profile/x_up_votes', $innervalue)).'';

line 651 (ca.):
// disabled minus points
/* $innervalue='<SPAN CLASS="qa-uf-user-downvoteds">'.number_format(@$userpoints['downvoteds']).'</SPAN>';
$votegotvalue.=(@$userpoints['downvoteds']==1) ? qa_lang_html_sub('profile/1_down_vote', $innervalue, '1')
    : qa_lang_html_sub('profile/x_down_votes', $innervalue);
*/


# qa-page.php
line 510-514:
/* changed order of navigation */
if (qa_opt('nav_ask') && (qa_user_permit_error('permit_post_q')!='level'))
    $qa_content['navigation']['main']['ask']=array(
        'url' => qa_path_html('ask', (qa_using_categories() && strlen($lastcategoryid)) ? array('cat' => $lastcategoryid) : null),
        'label' => qa_lang_html('main/nav_ask'),
    );

line 547 ca.:
/* changed: show user in Nav-Menu - only for logged in users */
if(qa_is_logged_in() ) {
    if (qa_opt('nav_users'))
        $qa_content['navigation']['main']['user']=array(
            'url' => qa_path_html('users'),
            'label' => qa_lang_html('main/nav_users'),
        );
}

line 555 ca.:
/* // do not show
if (qa_opt('nav_ask') && (qa_user_permit_error('permit_post_q')!='level'))
    $qa_content['navigation']['main']['ask']=array(
        'url' => qa_path_html('ask', (qa_using_categories() && strlen($lastcategoryid)) ? array('cat' => $lastcategoryid) : null),
        'label' => qa_lang_html('main/nav_ask'),
    );
*/

line 722 ca.:
// self-defined js version!
$qa_content['script_rel'][]='qa-content/qa-page.js?1.5.1'; // old: $qa_content['script_rel'][]='qa-content/qa-page.js?'.QA_VERSION;


# qa-theme-base.php
line 282:
// self-defined css version!
return 'qa-styles.css?1.5.1'; // return 'qa-styles.css?'.QA_VERSION;
 

Most of the hacks I discussed here in the forum, if there is no link provided above, you should find more background on each hack by searching the forum.

all the best,
Kai

 

@gidgreen: Maybe one or the other "hack" could be provided as an option in the admin frontend?

Q2A version: 1.5.1
by
What part is that first thing changing? Can't you do it with CSS?

Also "prevent that users can change their username" <- there is an option for that now, "Allow users with posts to change username".
by
edited by
This hack is formatting the notice on the ask-page: "Before proceeding, please check your question was not asked already" (similar questions). You are right, I removed the hack from above, and added css:

span#similar {font-weight:bold; font-size:14px; }
span#similar a {font-weight:normal; font-size:12px; }


// hack was:
# qa-ajax-asktitle.php
line 99:
echo '<span style="font-weight:bold;font-size:14px;">'.qa_lang_html('question/ask_same_q').'</span><BR/>'; // changed: added css bold + font-size
by
"There is an option for that now: Allow users with posts to change username" I know, I tried it, but it is not working if a user signed in via Facebook. He will still be able to change name + email.

So this hack needs to persist.
by
<b>As can be added to a moderator moderator and administrator can edit all</b>

# qa-page-question-view.php
 line 174 (added code):
 /* START added */
     // users are never allowed to hide posts
     $rules['hideable'] = false;
     /* users are not allowed to edit posts after 10 min */
     $timestamp = time(); // time now
     // 10 min time frame to edit
     $rules['editable'] = $rules['editbutton'] = $rules['isbyuser'] && ($timestamp - $post['created'] < 600);
     // admin has all rights
     $level=qa_get_logged_in_level();
     if ($level>=QA_USER_LEVEL_ADMIN) {
         $rules['editable'] = $rules['editbutton'] = $rules['hideable'] = true;
     }
     // only admin can close questions (and check if question is already closed)
     $rules['closeable'] = ($level>=QA_USER_LEVEL_ADMIN) && (!$rules['closed']);
 /* END added */

1 Answer

+1 vote
by

If you add this code does not work then edit the questions and answers for the moderator in a separate category. If you select a user in the same categories. He still can not edit the questions and answers of this category. These buttons disappear Post signle selected category.

 

# qa-page-question-view.php 
line 174 (added code): 
/* START added */ 
    // users are never allowed to hide posts 
    $rules['hideable'] = false; 
    /* users are not allowed to edit posts after 10 min */ 
    $timestamp = time(); // time now 
    // 10 min time frame to edit 
    $rules['editable'] = $rules['editbutton'] = $rules['isbyuser'] && ($timestamp - $post['created'] < 600); 
    // admin has all rights 
    $level=qa_get_logged_in_level(); 
    if ($level>=QA_USER_LEVEL_ADMIN) { 
        $rules['editable'] = $rules['editbutton'] = $rules['hideable'] = true; 
    } 
    // only admin can close questions (and check if question is already closed) 
    $rules['closeable'] = ($level>=QA_USER_LEVEL_ADMIN) && (!$rules['closed']); 
/* END added */ 

...