1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 14:17:49 +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); // optional, if $pluginName == 'core', core prefs will be used, else e107::getPluginConfig($pluginName);
protected $prefs = array( protected $prefs = array(
'add_faq' => array('title'=> LANA_FAQ_PREF_1, 'type'=>'userclass', 'help' => 'Under construction'), 'add_faq' => array('title'=> LANA_FAQ_PREF_1, 'type'=>'userclass' ),
'submit_question' => array('title'=> LANA_FAQ_PREF_2, 'type'=>'userclass', 'help' => 'Under construction'), 'submit_question' => array('title'=> LANA_FAQ_PREF_2, 'type'=>'userclass' ),
'classic_look' => array('title'=> LANA_FAQ_PREF_3, 'type'=>'boolean', 'help' => 'Under construction') '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(); 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_tags'] = implode(',', array_map('trim', explode(',', $new_data['faq_tags'])));
} }
$new_data['faq_order'] = 0;
return $new_data; return $new_data;
} }

View File

@@ -204,9 +204,11 @@ class faq
{ {
$sql = e107::getDb(); $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; return;
} }

View File

@@ -19,5 +19,5 @@ define('LANA_FAQ_METAD', 'Meta Description');
define('LANA_FAQ_METAK', 'Meta Keywords'); define('LANA_FAQ_METAK', 'Meta Keywords');
define('LANA_FAQ_PREF_1', 'Allow submitting of FAQs by:'); 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'); define('LANA_FAQ_PREF_3', 'Use Classic Layout');

View File

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

View File

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