Newer
Older
<?php
/*********************************************************************
faq.php
FAQs.
Peter Rotich <peter@osticket.com>
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
require('staff.inc.php');
require_once(INCLUDE_DIR.'class.faq.php');
$faq=$category=null;
if($_REQUEST['id'] && !($faq=FAQ::lookup($_REQUEST['id'])))
$errors['err']=__('Unknown or invalid FAQ');
if($_REQUEST['cid'] && !$faq && !($category=Category::lookup($_REQUEST['cid'])))
$errors['err']=__('Unknown or invalid FAQ category');
if($_POST):
$errors=array();
switch(strtolower($_POST['do'])) {
case 'create':
case 'add':
if(($faq=FAQ::add($_POST,$errors))) {
$msg=__('FAQ added successfully');
// Delete draft for this new faq
Draft::deleteForNamespace('faq', $thisstaff->getId());
} elseif(!$errors['err'])
$errors['err'] = __('Unable to add FAQ. Try again!');
break;
case 'update':
case 'edit';
if(!$faq)
$errors['err'] = __('Invalid or unknown FAQ');
$msg=__('FAQ updated successfully');
$faq->reload();
// Delete pending draft updates for this faq (for ALL users)
Draft::deleteForNamespace('faq.'.$faq->getId());
$errors['err'] = __('Unable to update FAQ. Try again!');
$errors['err']=__('Unknown or invalid FAQ');
} else {
switch(strtolower($_POST['a'])) {
case 'edit':
$_GET['a']='edit';
break;
case 'publish';
if($faq->publish())
$msg=__('FAQ published successfully');
$errors['err']=__('Unable to publish the FAQ. Try editing it.');
break;
case 'unpublish';
if($faq->unpublish())
$msg=__('FAQ unpublished successfully');
$errors['err']=__('Unable to unpublish the FAQ. Try editing it.');
break;
case 'delete':
$category = $faq->getCategory();
if($faq->delete()) {
$msg=__('FAQ deleted successfully');
$errors['err']=__('Unable to delete FAQ. Try again');
$errors['err']=__('Invalid action');
$errors['err']=__('Unknown action');
}
endif;
$inc='faq-categories.inc.php'; //FAQs landing page.
if($faq) {
$inc='faq-view.inc.php';
if($_REQUEST['a']=='edit' && $thisstaff->canManageFAQ())
$inc='faq.inc.php';
}elseif($_REQUEST['a']=='add' && $thisstaff->canManageFAQ()) {
$inc='faq.inc.php';
} elseif($category && $_REQUEST['a']!='search') {
$inc='faq-category.inc.php';
}
$ost->addExtraHeader('<meta name="tip-namespace" content="' . $tip_namespace . '" />',
"$('#content').data('tipNamespace', '".$tip_namespace."');");
require_once(STAFFINC_DIR.'header.inc.php');
require_once(STAFFINC_DIR.$inc);
require_once(STAFFINC_DIR.'footer.inc.php');
?>