1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 06:07:32 +02:00

Plugin FAQs: Added "Ask a Question" limit preference

This commit is contained in:
Cameron
2015-04-02 12:34:32 -07:00
parent 1740161a49
commit 077489bb72
5 changed files with 19 additions and 6 deletions

View File

@@ -209,9 +209,11 @@ class faq_main_ui extends e_admin_ui
// optional, if $pluginName == 'core', core prefs will be used, else e107::getPluginConfig($pluginName);
protected $prefs = array(
'add_faq' => array('title'=> LANA_FAQ_PREF_1, 'type'=>'userclass', 'help' => 'Under construction'),
'submit_question' => array('title'=> LANA_FAQ_PREF_2, 'type'=>'userclass', 'help' => 'Under construction'),
'classic_look' => array('title'=> LANA_FAQ_PREF_3, 'type'=>'boolean', 'help' => 'Under construction')
'add_faq' => array('title'=> LANA_FAQ_PREF_1, 'type'=>'userclass' ),
'submit_question' => array('title'=> LANA_FAQ_PREF_2, 'type'=>'userclass' ),
'submit_question_limit' => array('title'=> "'Ask a Question' limit per user", 'type'=>'number', 'data'=>'int', 'help'=>'0 = no limit'),
'classic_look' => array('title'=> LANA_FAQ_PREF_3, 'type'=>'boolean' ),
);
protected $categories = array();
@@ -240,6 +242,8 @@ class faq_main_ui extends e_admin_ui
$new_data['faq_tags'] = implode(',', array_map('trim', explode(',', $new_data['faq_tags'])));
}
$new_data['faq_order'] = 0;
return $new_data;
}

View File

@@ -204,9 +204,11 @@ class faq
{
$sql = e107::getDb();
if($sql->select('faqs','faq_id',"faq_answer='' AND faq_author_ip = '".USERIP."' LIMIT 1"))
$existing = $sql->select('faqs','faq_id',"faq_answer='' AND faq_author_ip = '".USERIP."' ");
if(!empty($this->pref['submit_question_limit']) && $existing >= $this->pref['submit_question_limit'])
{
e107::getMessage()->setTitle('Sorry',E_MESSAGE_INFO)->addInfo("You may only ask another question once your other question has been answered.");
e107::getMessage()->setTitle('Sorry',E_MESSAGE_INFO)->addInfo("You have reached the maximum number of new questions. You may ask more once your existing questions have been answered.");
return;
}

View File

@@ -19,5 +19,5 @@ define('LANA_FAQ_METAD', 'Meta Description');
define('LANA_FAQ_METAK', 'Meta Keywords');
define('LANA_FAQ_PREF_1', 'Allow submitting of FAQs by:');
define('LANA_FAQ_PREF_2', 'Allow submitting of Questions by:');
define('LANA_FAQ_PREF_2', "'Ask a Question' is limited to");
define('LANA_FAQ_PREF_3', 'Use Classic Layout');

View File

@@ -20,6 +20,7 @@
<pluginPrefs>
<pref name="add_faq">255</pref>
<pref name="submit_question">255</pref>
<pref name="submit_question_limit">3</pref>
<pref name="classic_look">0</pref>
</pluginPrefs>
</e107Plugin>

View File

@@ -239,6 +239,11 @@ class wysiwyg
return $string;
}
if(is_numeric($string))
{
return $string;
}
if(is_string($string))
{
$string = trim($string);
@@ -325,6 +330,7 @@ class wysiwyg
$ret['preformatted'] = true;
$ret['document_base_url'] = SITEURL;
// $ret['table_default_attributes'] = json_encode(array('class'=>'table table-striped' ));