diff --git a/e107_plugins/faqs/admin_config.php b/e107_plugins/faqs/admin_config.php index 54353cf10..14ca9fb0f 100644 --- a/e107_plugins/faqs/admin_config.php +++ b/e107_plugins/faqs/admin_config.php @@ -40,6 +40,8 @@ class faq_admin extends e_admin_dispatcher protected $adminMenu = array( 'main/list' => array('caption'=> LAN_MANAGE, 'perm' => 'P'), 'main/create' => array('caption'=> LAN_CREATE_ITEM, 'perm' => 'P'), + 'main/followup' => array('caption'=> "Unanswered", 'perm' => 'P', 'uri'=>"admin_config.php?searchquery=&filter_options=faq_author__0&mode=main&action=list"), + 'cat/list' => array('caption'=> LAN_CATEGORIES, 'perm' => 'P'), 'cat/create' => array('caption'=> LAN_CREATE_CATEGORY, 'perm' => 'P'), 'main/prefs' => array('caption'=> LAN_PREFS, 'perm' => '0'), @@ -51,6 +53,8 @@ class faq_admin extends e_admin_dispatcher ); protected $menuTitle = 'FAQs'; + + // } class faq_cat_ui extends e_admin_ui @@ -191,8 +195,10 @@ class faq_main_ui extends e_admin_ui 'faq_comment' => array('title'=> LANA_FAQ_COMMENT, 'tab' => 1, 'type' => 'userclass', 'data' => 'int', 'width' => 'auto', 'inline'=> true), // User id 'faq_datestamp' => array('title'=> LAN_DATE, 'tab' => 1, 'type' => 'datestamp', 'data'=> 'int','width' => 'auto', 'noedit' => false,'writeParms'=>'auto=1'), - 'faq_author' => array('title'=> LAN_USER, 'tab' => 1, 'type' => 'user', 'data'=> 'int', 'width' => 'auto', 'thclass' => 'center', 'class'=>'center', 'writeParms' => 'currentInit=1', 'filter' => true, 'batch' => true, 'nolist' => true ), // Photo - 'u.user_name' => array('title'=> LANA_FAQ_UNAME, 'tab' => 1, 'type' => 'user', 'width' => 'auto', 'noedit' => true, 'readParms'=>'idField=faq_author&link=1'), // User name + 'faq_author' => array('title'=> LAN_USER, 'tab' => 1, 'type' => 'user', 'data'=> 'int', 'width' => 'auto', 'thclass' => 'center', 'class'=>'center', 'writeParms' => 'currentInit=1', 'filter' => true, 'batch' => true, 'nolist' => true ), // Photo + 'faq_author_ip' => array('title'=> LAN_IP, 'tab' => 1, 'type' => 'ip', 'readonly'=>2, 'data'=> 'str', 'width' => 'auto', 'thclass' => 'center', 'class'=>'center', 'writeParms' => 'currentInit=1', 'filter' => true, 'batch' => true, 'nolist' => true ), // Photo + + 'u.user_name' => array('title'=> LANA_FAQ_UNAME, 'tab' => 1, 'type' => 'user', 'width' => 'auto', 'noedit' => true, 'readParms'=>'idField=faq_author&link=1'), // User name 'u.user_loginname' => array('title'=> LANA_FAQ_ULOGINNAME, 'tab' => 1, 'type' => 'user', 'width' => 'auto', 'noedit' => true, 'readParms'=>'idField=faq_author&link=1'), // User login name 'faq_order' => array('title'=> LAN_ORDER, 'tab' => 1, 'type' => 'number', 'data'=> 'int','width' => '5%', 'thclass' => 'center','nolist' => false, 'noedit'=>false, 'readParms'=>'editable=1'), 'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center','readParms'=>'sort=1') diff --git a/e107_plugins/faqs/e_url.php b/e107_plugins/faqs/e_url.php index 625626f18..379a34618 100644 --- a/e107_plugins/faqs/e_url.php +++ b/e107_plugins/faqs/e_url.php @@ -31,13 +31,21 @@ class faqs_url // plugin-folder + '_url' 'redirect' => '{e_PLUGIN}faqs/faqs.php', // file-path of what to load when the regex returns true. ); + + $config['tag'] = array( + 'regex' => '^faqs/tag/(.*)$', + 'sef' => 'faqs/tag/{tag}', // {faq_info_sef} is substituted with database value when parsed by e107::url(); + 'redirect' => '{e_PLUGIN}faqs/faqs.php?tag=$1' + ); $config['category'] = array( 'regex' => '^faqs/(.*)$', 'sef' => 'faqs/{faq_info_sef}', // {faq_info_sef} is substituted with database value when parsed by e107::url(); 'redirect' => '{e_PLUGIN}faqs/faqs.php?cat=$1' ); - + + + return $config; } diff --git a/e107_plugins/faqs/faqs.css b/e107_plugins/faqs/faqs.css index 51e04a3ca..66eadf388 100644 --- a/e107_plugins/faqs/faqs.css +++ b/e107_plugins/faqs/faqs.css @@ -9,9 +9,14 @@ margin-top:20px; margin-left:30px; } -.faq-submit-question + +div.faq-tags { font-size: 80%; text-align:right } + +a.faq-submit-question { - margin-top:20px; + text-align:right; + float: right; + margin-top:-50px; margin-bottom: 10px; } @@ -50,8 +55,9 @@ li.faq-listall-loop .faq-answer { - margin:20px; - border:1px solid silver; - background-color: #e3e3e3; + margin:20px 0px; + border:1px solid #DDDDDD; + background-color: #F5F5F5; padding:10px; + border-radius: 5px; } diff --git a/e107_plugins/faqs/faqs.php b/e107_plugins/faqs/faqs.php index 7e7f7e16d..07bb1ff31 100644 --- a/e107_plugins/faqs/faqs.php +++ b/e107_plugins/faqs/faqs.php @@ -27,7 +27,7 @@ if(file_exists(e_PLUGIN."faqs/controllers/list.php")) } else { - include_lan(e_PLUGIN."faqs/languages/".e_LANGUAGE."/".e_LANGUAGE."_global.php"); + e107::includeLan(e_PLUGIN."faqs/languages/".e_LANGUAGE."/".e_LANGUAGE."_front.php"); } @@ -49,6 +49,8 @@ if (!vartrue($FAQ_VIEW_TEMPLATE)) } } + +e107::css('faqs','faqs.css'); // require_once(HEADERF); // $pref['add_faq']=1; @@ -135,7 +137,8 @@ if (isset($_POST['commentsubmit'])) { $srch = vartrue($_GET['srch']); $ftmp = $faq->view_all($srch); - $caption = FAQLAN_FAQ; + $caption = FAQLAN_FAQ; + } if (vartrue($faqpref['faq_title'])) @@ -196,8 +199,45 @@ class faq $this->pref = e107::pref('faqs'); // Short version of e107::getPlugConfig('faqs')->getPref(); ; $sc->pref = $this->pref; + + if(!empty($_POST['submit_a_question'])) + { + $sql = e107::getDb(); + + if($sql->select('faqs','faq_id',"faq_answer='' AND faq_author_ip = '".USERIP."' LIMIT 1")) + { + e107::getMessage()->setTitle('Sorry',E_MESSAGE_INFO)->addInfo("You may only ask another question once your other question has been answered."); + return; + } + + $question = filter_input(INPUT_POST, 'ask_a_question', FILTER_SANITIZE_STRING); + + $insert = array( + 'faq_id' =>0, + 'faq_parent' =>0, + 'faq_question' => $question, + 'faq_answer' => '', + 'faq_comment' => 0, + 'faq_datestamp' => time(), + 'faq_author' => 0, + 'faq_author_ip' => USERIP, + 'faq_tags' => '', + 'faq_order' => 99999 + ); + + if($sql->insert('faqs',$insert)) + { + e107::getMessage()->addSuccess('Thank you. Your question has been saved and will be answered as soon as possible.'); + } + + } + + + } + + function view_all($srch) // new funtion to render all FAQs { $sql = e107::getDb(); @@ -211,7 +251,7 @@ class faq $this->sc = e107::getScBatch('faqs',TRUE); - $text = $tp->parseTemplate($template['start'], true, $this->sc); + $text = $tp->parseTemplate($template['start'], true, $this->sc); // header // var_dump($sc); @@ -221,7 +261,7 @@ class faq $text .= ""; - $text .= $tp->parseTemplate($template['end'], true, $this->sc); + $text .= $tp->parseTemplate($template['end'], true, $this->sc); // footer @@ -240,6 +280,8 @@ class faq { $sql = e107::getDb(); $tp = e107::getParser(); + + $text = ""; $insert = ""; @@ -252,7 +294,21 @@ class faq if(!empty($_GET['cat'])) { $srch = $tp->toDB($_GET['cat']); - $insert = " AND (cat.faq_info_sef = '".$srch."') "; + $insert = " AND (cat.faq_info_sef = '".$srch."') "; + } + + if(!empty($_GET['tag'])) + { + $srch = $tp->toDB($_GET['tag']); + + + $insert = " AND FIND_IN_SET ('".$srch."', f.faq_tags) "; + + $removeUrl = e107::url('faqs','index'); + $message = "".$srch." ×"; + + e107::getMessage()->setClose(false,E_MESSAGE_INFO)->setTitle(LAN_FAQS_FILTER_ACTIVE,E_MESSAGE_INFO)->addInfo($message); + $text = e107::getMessage()->render(); } $query = "SELECT f.*,cat.* FROM #faqs AS f LEFT JOIN #faqs_info AS cat ON f.faq_parent = cat.faq_info_id WHERE cat.faq_info_class IN (".USERCLASS_LIST.") ".$insert." ORDER BY cat.faq_info_order,f.faq_order "; @@ -264,20 +320,18 @@ class faq // ----------------- - $FAQ_START = e107::getTemplate('faqs', true, 'start'); - $FAQ_END = e107::getTemplate('faqs', true, 'end'); $FAQ_LISTALL = e107::getTemplate('faqs', true, 'all'); - $FAQ_CAPTION = e107::getTemplate('faqs', true, 'caption'); - - - $prevcat = ""; + + $prevcat = ""; $sc = e107::getScBatch('faqs', true); $sc->counter = 1; $sc->tag = htmlspecialchars($tag, ENT_QUOTES, 'utf-8'); $sc->category = $category; - $text = $tp->parseTemplate($FAQ_START, true, $sc); - + // $text = $tp->parseTemplate($FAQ_START, true, $sc); + + // $text = ""; + while ($rw = $sql->fetch()) { $sc->setVars($rw); @@ -298,8 +352,8 @@ class faq $sc->counter++; } $text .= ($start) ? $tp->parseTemplate($FAQ_LISTALL['end'], true, $sc) : ""; - $text .= $tp->parseTemplate($FAQ_END, true, $sc); - +// $text .= $tp->parseTemplate($FAQ_END, true, $sc); + return $text; } diff --git a/e107_plugins/faqs/faqs_shortcodes.php b/e107_plugins/faqs/faqs_shortcodes.php index 912a0808c..3f5e84655 100644 --- a/e107_plugins/faqs/faqs_shortcodes.php +++ b/e107_plugins/faqs/faqs_shortcodes.php @@ -44,7 +44,7 @@ class faqs_shortcodes extends e_shortcode $tags = ''; if(vartrue($params['tags']) && $this->var['faq_tags']) { - $tags = "
"; + $tags = " "; } $id = "faq_".$this->var['faq_id']; $text = "".$tp->toHTML($this->var['faq_question'],true)." @@ -84,7 +84,8 @@ class faqs_shortcodes extends e_shortcode foreach ($tags as $tag) { $urlparms['tag'] = $tag; - $url = e107::getUrl()->create('faqs/list/all', $urlparms); + // $url = e107::getUrl()->create('faqs/list/all', $urlparms); + $url = e107::url('faqs', 'tag',$urlparms); $tag = htmlspecialchars($tag, ENT_QUOTES, 'utf-8'); $ret[] = ''.$tag.''; } @@ -181,22 +182,27 @@ class faqs_shortcodes extends e_shortcode function sc_faq_submit_question() { - return ''; // UNDER CONSTRUCTION - $faqpref = e107::getPlugConfig('faqs')->getPref(); - $frm = e107::getForm(); - - if (check_class($faqpref['add_faq'])) + + $faqpref = e107::pref('faqs'); + + if (check_class($faqpref['submit_question'])) { - $text = "