Redirect with some message
Access check: If this user is allowed to access the component?
Raise warning or error
SEF redirect
Transaction in joomla
Check if SEF url is on and get menu alias if on
$app = JFactory::getApplication();
$link = JRoute::_('index.php?option=com_users&view=login');
$msg = JText::_('JERROR_ALERTNOAUTHOR');
$app->redirect($link, $msg, 'warning');
Access check: If this user is allowed to access the component?
if (!JFactory::getUser()->authorise('yourcomponentname.yourdefindaccess', 'com_yourcomponentname')) {
//do actions like raise error or redirect
}
Raise warning or error
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
SEF redirect
$mainframe = JFactory::getApplication();
$mainframe->redirect(JRoute::_("index.php?option=com_yourcomponentname&view=yourcomponentview", false));
Transaction in joomla
$db = JFactory::getDbo();
try {
$db->transactionStart();
//code here
$rolledBack = $db->transactionCommit();
} catch (Exception $e) {
$db->transactionRollback();
}
Check if SEF url is on and get menu alias if on
$conf = &JFactory::getConfig();
if( $conf->get('sef') == 1 ){
$menu = JSite::getMenu();
$alias = $menu->getItem(483)->alias;
}
No comments:
Post a Comment