本文整理汇总了PHP中JApplicationCms::enqueueMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP JApplicationCms::enqueueMessage方法的具体用法?PHP JApplicationCms::enqueueMessage怎么用?PHP JApplicationCms::enqueueMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JApplicationCms
的用法示例。
在下文中一共展示了JApplicationCms::enqueueMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Execute the controller.
*
* @return boolean True if controller finished execution, false if the controller did not
* finish execution. A controller might return false if some precondition for
* the controller to run has not been satisfied.
*
* @since 12.1
* @throws LogicException
* @throws RuntimeException
*/
public function execute()
{
$model = new MonitorModelIssue();
$id = $this->input->getInt('id');
$user = JFactory::getUser();
// Get the params
// TODO: may be removed when new MVC is implemented completely
$this->app = JFactory::getApplication();
if ($this->app instanceof JApplicationSite) {
$params = $this->app->getParams();
}
if (!$model->canEdit($user, $id)) {
if ($user->guest && isset($params) && $params->get('redirect_login', 1)) {
$this->app->enqueueMessage(JText::_('JGLOBAL_YOU_MUST_LOGIN_FIRST'), 'error');
$this->app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode(JUri::getInstance()->toString()), '403'));
} else {
throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}
}
if ($id) {
$model->setIssueId($id);
}
$model->loadForm();
$view = new MonitorViewIssueHtml($model);
$view->setLayout('edit');
$view->loadForm();
echo $view->render();
return true;
}
示例2: execute
/**
* Method to remove root in global configuration.
*
* @return boolean True on success.
*
* @since 3.2
*/
public function execute()
{
// Check for request forgeries.
if (!JSession::checkToken('get')) {
$this->app->enqueueMessage(JText::_('JINVALID_TOKEN'));
$this->app->redirect('index.php');
}
// Check if the user is authorized to do this.
if (!JFactory::getUser()->authorise('core.admin')) {
$this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'));
$this->app->redirect('index.php');
}
// Initialise model.
$model = new ConfigModelApplication();
// Attempt to save the configuration and remove root.
try {
$model->removeroot();
} catch (RuntimeException $e) {
// Save failed, go back to the screen and display a notice.
$this->app->enqueueMessage(JText::sprintf('JERROR_SAVE_FAILED', $e->getMessage()), 'error');
$this->app->redirect(JRoute::_('index.php', false));
}
// Set the redirect based on the task.
$this->app->enqueueMessage(JText::_('COM_CONFIG_SAVE_SUCCESS'));
$this->app->redirect(JRoute::_('index.php', false));
}
示例3: execute
/**
* Method to save global configuration.
*
* @return boolean True on success.
*
* @since 3.2
*/
public function execute()
{
// Check for request forgeries.
if (!JSession::checkToken()) {
$this->app->enqueueMessage(JText::_('JINVALID_TOKEN'));
$this->app->redirect('index.php');
}
// Check if the user is authorized to do this.
if (!JFactory::getUser()->authorise('core.admin')) {
$this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'));
$this->app->redirect('index.php');
}
// Set FTP credentials, if given.
JClientHelper::setCredentialsFromRequest('ftp');
$model = new ConfigModelConfig();
$form = $model->getForm();
$data = $this->input->post->get('jform', array(), 'array');
// Validate the posted data.
$return = $model->validate($form, $data);
// Check for validation errors.
if ($return === false) {
/*
* The validate method enqueued all messages for us, so we just need to redirect back.
*/
// Save the data in the session.
$this->app->setUserState('com_config.config.global.data', $data);
// Redirect back to the edit screen.
$this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.config', false));
}
// Attempt to save the configuration.
$data = $return;
// Access back-end com_config
JLoader::registerPrefix('Config', JPATH_ADMINISTRATOR . '/components/com_config');
$saveClass = new ConfigControllerApplicationSave();
// Get a document object
$document = JFactory::getDocument();
// Set back-end required params
$document->setType('json');
// Execute back-end controller
$return = $saveClass->execute();
// Reset params back after requesting from service
$document->setType('html');
// Check the return value.
if ($return === false) {
/*
* The save method enqueued all messages for us, so we just need to redirect back.
*/
// Save the data in the session.
$this->app->setUserState('com_config.config.global.data', $data);
// Save failed, go back to the screen and display a notice.
$this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.config', false));
}
// Redirect back to com_config display
$this->app->enqueueMessage(JText::_('COM_CONFIG_SAVE_SUCCESS'));
$this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.config', false));
return true;
}
示例4: __construct
public function __construct(&$subject, $config = array())
{
$this->app = JFactory::getApplication();
JLoader::register('Gantry5\\Loader', JPATH_LIBRARIES . '/gantry5/Loader.php');
// Detect Gantry Framework or fail gracefully.
if (!class_exists('Gantry5\\Loader')) {
if ($this->app->isAdmin()) {
$this->loadLanguage('plg_system_gantry5.sys');
$this->app->enqueueMessage(JText::sprintf('PLG_SYSTEM_GANTRY5_LIBRARY_MISSING', JText::_('PLG_SYSTEM_GANTRY5')), 'warning');
}
return;
}
parent::__construct($subject, $config);
}
示例5: execute
/**
* Execute the controller.
*
* @return boolean True if controller finished execution, false if the controller did not
* finish execution. A controller might return false if some precondition for
* the controller to run has not been satisfied.
*
* @since 12.1
* @throws LogicException
* @throws RuntimeException
*/
public function execute()
{
$id = $this->input->getInt('id');
$user = JFactory::getUser();
if ($user->guest) {
$this->app->enqueueMessage(JText::_('JGLOBAL_YOU_MUST_LOGIN_FIRST'), 'error');
} else {
$model = new MonitorModelSubscription();
if ($model->isSubscriberIssue($id, $user->id)) {
$model->unsubscribeIssue($id, $user->id);
$this->app->enqueueMessage(JText::_('COM_MONITOR_SUBSCRIPTION_ISSUE_UNSUBSCRIBED'), 'message');
}
}
$this->app->redirect(JRoute::_('index.php?option=com_monitor&view=issue&id=' . $id, false));
}
示例6: validate
/**
* Validates data from a form.
*
* @param array $data The data to validate.
* @param JForm $form The form to use for validation.
*
* @return mixed|bool Array of filtered data if valid, false otherwise.
*
* @see ConfigModelForm::validate
*/
public function validate($data, $form = null)
{
if (!$form) {
if (!$this->form) {
$this->loadForm();
}
$form = $this->form;
}
// Filter and validate the form data.
$data = $form->filter($data);
$return = $form->validate($data);
// Store data for eventual redirects.
$this->app->setUserState($form->getName() . '.data', $data);
// Check for an error.
if ($return instanceof Exception) {
$this->app->enqueueMessage($return->getMessage(), 'error');
return false;
}
// Check the validation results.
if ($return === false) {
// Get the validation messages from the form.
foreach ($form->getErrors() as $message) {
$this->app->enqueueMessage($message->getMessage(), 'error');
}
return false;
}
$this->app->setUserState($form->getName() . '.data', null);
return $data;
}
示例7: execute
/**
* Method to refresh help in global configuration.
*
* @return boolean True on success.
*
* @since 3.2
*/
public function execute()
{
jimport('joomla.filesystem.file');
// Set FTP credentials, if given
JClientHelper::setCredentialsFromRequest('ftp');
if (($data = file_get_contents('http://help.joomla.org/helpsites.xml')) === false) {
$this->app->enqueueMessage(JText::_('COM_CONFIG_ERROR_HELPREFRESH_FETCH'), 'error');
$this->app->redirect(JRoute::_('index.php?option=com_config', false));
} elseif (!JFile::write(JPATH_BASE . '/help/helpsites.xml', $data)) {
$this->app->enqueueMessage(JText::_('COM_CONFIG_ERROR_HELPREFRESH_ERROR_STORE'), 'error');
$this->app->redirect(JRoute::_('index.php?option=com_config', false));
} else {
$this->app->enqueueMessage(JText::_('COM_CONFIG_HELPREFRESH_SUCCESS'), 'error');
$this->app->redirect(JRoute::_('index.php?option=com_config', false));
}
}
示例8: onGetIcons
/**
* Check the PHP version after the admin component has been dispatched.
*
* @param string $context The calling context
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function onGetIcons($context)
{
if (!$this->shouldDisplayMessage()) {
return;
}
$supportStatus = $this->getPhpSupport();
if ($supportStatus['status'] !== self::PHP_SUPPORTED) {
// Enqueue the notification message; set a warning if receiving security support or "error" if unsupported
switch ($supportStatus['status']) {
case self::PHP_SECURITY_ONLY:
$this->app->enqueueMessage($supportStatus['message'], 'warning');
break;
case self::PHP_UNSUPPORTED:
$this->app->enqueueMessage($supportStatus['message'], 'error');
break;
}
}
}
示例9: execute
/**
* Execute the controller.
*
* @return boolean True if controller finished execution, false if the controller did not
* finish execution. A controller might return false if some precondition for
* the controller to run has not been satisfied.
*
* @since 12.1
* @throws LogicException
* @throws RuntimeException
*/
public function execute()
{
$id = $this->input->getInt('id');
$user = JFactory::getUser();
if ($user->guest) {
$this->app->enqueueMessage(JText::_('JGLOBAL_YOU_MUST_LOGIN_FIRST'), 'error');
} else {
$model = new MonitorModelSubscription();
if (!$model->isSubscriberProject($id, $user->id)) {
$model->subscribeProject($id, $user->id);
$this->app->enqueueMessage(JText::_('COM_MONITOR_SUBSCRIPTION_PROJECT'), 'message');
}
}
$return = base64_decode($this->app->input->get('return', '', 'BASE64'));
if (!JUri::isInternal($return)) {
$return = 'index.php?option=com_monitor&view=project&id=' . $id;
}
$this->app->redirect(JRoute::_($return, false));
}
示例10: execute
/**
* Execute the controller.
*
* @return mixed A rendered view or true
*
* @since 3.2
*/
public function execute()
{
// Get the document object.
$document = JFactory::getDocument();
$componentFolder = $this->input->getWord('option', 'com_config');
if ($this->app->isAdmin()) {
$viewName = $this->input->getWord('view', 'application');
} else {
$viewName = $this->input->getWord('view', 'config');
}
$viewFormat = $document->getType();
$layoutName = $this->input->getWord('layout', 'default');
// Register the layout paths for the view
$paths = new SplPriorityQueue();
if ($this->app->isAdmin()) {
$paths->insert(JPATH_ADMINISTRATOR . '/components/' . $componentFolder . '/view/' . $viewName . '/tmpl', 1);
} else {
$paths->insert(JPATH_BASE . '/components/' . $componentFolder . '/view/' . $viewName . '/tmpl', 1);
}
$viewClass = $this->prefix . 'View' . ucfirst($viewName) . ucfirst($viewFormat);
$modelClass = $this->prefix . 'Model' . ucfirst($viewName);
if (class_exists($viewClass)) {
$model = new $modelClass();
$component = $model->getState()->get('component.option');
// Access check.
if (!JFactory::getUser()->authorise('core.admin', $component) && !JFactory::getUser()->authorise('core.options', $component)) {
$this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error');
return;
}
$view = new $viewClass($model, $paths);
$view->setLayout($layoutName);
// Push document object into the view.
$view->document = $document;
// Reply for service requests
if ($viewFormat == 'json') {
return $view->render();
}
// Render view.
echo $view->render();
}
return true;
}
示例11: onUserLogin
/**
* This method should handle any login logic and report back to the subject
*
* @param array $user Holds the user data
* @param array $options Array holding options (remember, autoregister, group)
*
* @return boolean True on success
*
* @since 1.5
*/
public function onUserLogin($user, $options = array())
{
$instance = $this->_getUser($user, $options);
// If _getUser returned an error, then pass it back.
if ($instance instanceof Exception) {
return false;
}
// If the user is blocked, redirect with an error
if ($instance->block == 1) {
$this->app->enqueueMessage(JText::_('JERROR_NOLOGIN_BLOCKED'), 'warning');
return false;
}
// Authorise the user based on the group information
if (!isset($options['group'])) {
$options['group'] = 'USERS';
}
// Check the user can login.
$result = $instance->authorise($options['action']);
if (!$result) {
$this->app->enqueueMessage(JText::_('JERROR_LOGIN_DENIED'), 'warning');
return false;
}
// Mark the user as logged in
$instance->guest = 0;
$session = JFactory::getSession();
// Grab the current session ID
$oldSessionId = $session->getId();
// Fork the session
$session->fork();
$session->set('user', $instance);
// Ensure the new session's metadata is written to the database
$this->app->checkSession();
// Purge the old session
$query = $this->db->getQuery(true)->delete('#__session')->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($oldSessionId));
try {
$this->db->setQuery($query)->execute();
} catch (RuntimeException $e) {
// The old session is already invalidated, don't let this block logging in
}
// Hit the user last visit field
$instance->setLastVisit();
// Add "user state" cookie used for reverse caching proxies like Varnish, Nginx etc.
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('cookie_domain', '');
$cookie_path = $conf->get('cookie_path', '/');
if ($this->app->isSite()) {
$this->app->input->cookie->set("joomla_user_state", "logged_in", 0, $cookie_path, $cookie_domain, 0);
}
return true;
}
示例12: onUserLogin
/**
* This method should handle any login logic and report back to the subject
*
* @param array $user Holds the user data
* @param array $options Array holding options (remember, autoregister, group)
*
* @return boolean True on success
*
* @since 1.5
*/
public function onUserLogin($user, $options = array())
{
$instance = $this->_getUser($user, $options);
// If _getUser returned an error, then pass it back.
if ($instance instanceof Exception) {
return false;
}
// If the user is blocked, redirect with an error
if ($instance->get('block') == 1) {
$this->app->enqueueMessage(JText::_('JERROR_NOLOGIN_BLOCKED'), 'warning');
return false;
}
// Authorise the user based on the group information
if (!isset($options['group'])) {
$options['group'] = 'USERS';
}
// Check the user can login.
$result = $instance->authorise($options['action']);
if (!$result) {
$this->app->enqueueMessage(JText::_('JERROR_LOGIN_DENIED'), 'warning');
return false;
}
// Mark the user as logged in
$instance->set('guest', 0);
// Register the needed session variables
$session = JFactory::getSession();
$session->set('user', $instance);
// Check to see the the session already exists.
$this->app->checkSession();
// Update the user related fields for the Joomla sessions table.
$query = $this->db->getQuery(true)->update($this->db->quoteName('#__session'))->set($this->db->quoteName('guest') . ' = ' . $this->db->quote($instance->guest))->set($this->db->quoteName('username') . ' = ' . $this->db->quote($instance->username))->set($this->db->quoteName('userid') . ' = ' . (int) $instance->id)->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($session->getId()));
try {
$this->db->setQuery($query)->execute();
} catch (RuntimeException $e) {
return false;
}
// Hit the user last visit field
$instance->setLastVisit();
// Add "user state" cookie used for reverse caching proxies like Varnish, Nginx etc.
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('cookie_domain', '');
$cookie_path = $conf->get('cookie_path', '/');
if ($this->app->isSite()) {
$this->app->input->cookie->set("joomla_user_state", "logged_in", 0, $cookie_path, $cookie_domain, 0);
}
return true;
}
示例13: onUserLogin
/**
* This method should handle any login logic and report back to the subject
*
* @param array $user Holds the user data
* @param array $options Array holding options (remember, autoregister, group)
*
* @return boolean True on success
*
* @since 1.5
*/
public function onUserLogin($user, $options = array())
{
$instance = $this->_getUser($user, $options);
// If _getUser returned an error, then pass it back.
if ($instance instanceof Exception) {
return false;
}
// If the user is blocked, redirect with an error
if ($instance->get('block') == 1) {
$this->app->enqueueMessage(JText::_('JERROR_NOLOGIN_BLOCKED'), 'warning');
return false;
}
// Authorise the user based on the group information
if (!isset($options['group'])) {
$options['group'] = 'USERS';
}
// Check the user can login.
$result = $instance->authorise($options['action']);
if (!$result) {
$this->app->enqueueMessage(JText::_('JERROR_LOGIN_DENIED'), 'warning');
return false;
}
// Mark the user as logged in
$instance->set('guest', 0);
// If the user has an outdated hash, update it.
if (substr($user['password'], 0, 4) != '$2y$' && $this->useStrongEncryption && JCrypt::hasStrongPasswordSupport() == true) {
if (strlen($user['password']) > 55) {
$user['password'] = substr($user['password'], 0, 55);
JFactory::getApplication()->enqueueMessage(JText::_('JLIB_USER_ERROR_PASSWORD_TRUNCATED'), 'notice');
}
$instance->password = password_hash($user['password'], PASSWORD_BCRYPT);
$instance->save();
}
// Register the needed session variables
$session = JFactory::getSession();
$session->set('user', $instance);
// Check to see the the session already exists.
$this->app->checkSession();
// Update the user related fields for the Joomla sessions table.
$query = $this->db->getQuery(true)->update($this->db->quoteName('#__session'))->set($this->db->quoteName('guest') . ' = ' . $this->db->quote($instance->guest))->set($this->db->quoteName('username') . ' = ' . $this->db->quote($instance->username))->set($this->db->quoteName('userid') . ' = ' . (int) $instance->id)->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($session->getId()));
$this->db->setQuery($query)->execute();
// Hit the user last visit field
$instance->setLastVisit();
return true;
}
示例14: onUserLogin
/**
* This method should handle any login logic and report back to the subject
*
* @param array $user Holds the user data
* @param array $options Array holding options (remember, autoregister, group)
*
* @return boolean True on success
*
* @since 1.5
*/
public function onUserLogin($user, $options = array())
{
$instance = $this->_getUser($user, $options);
// If _getUser returned an error, then pass it back.
if ($instance instanceof Exception) {
return false;
}
// If the user is blocked, redirect with an error
if ($instance->get('block') == 1) {
$this->app->enqueueMessage(JText::_('JERROR_NOLOGIN_BLOCKED'), 'warning');
return false;
}
// Authorise the user based on the group information
if (!isset($options['group'])) {
$options['group'] = 'USERS';
}
// Check the user can login.
$result = $instance->authorise($options['action']);
if (!$result) {
$this->app->enqueueMessage(JText::_('JERROR_LOGIN_DENIED'), 'warning');
return false;
}
// Mark the user as logged in
$instance->set('guest', 0);
// Register the needed session variables
$session = JFactory::getSession();
$session->set('user', $instance);
// Check to see the the session already exists.
$this->app->checkSession();
// Update the user related fields for the Joomla sessions table.
$query = $this->db->getQuery(true)->update($this->db->quoteName('#__session'))->set($this->db->quoteName('guest') . ' = ' . $this->db->quote($instance->guest))->set($this->db->quoteName('username') . ' = ' . $this->db->quote($instance->username))->set($this->db->quoteName('userid') . ' = ' . (int) $instance->id)->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($session->getId()));
$this->db->setQuery($query)->execute();
// Hit the user last visit field
$instance->setLastVisit();
return true;
}
示例15: execute
/**
* Method to save global configuration.
*
* @return mixed Calls $app->redirect() for all cases except JSON
*
* @since 3.2
*/
public function execute()
{
// Check for request forgeries.
if (!JSession::checkToken()) {
$this->app->enqueueMessage(JText::_('JINVALID_TOKEN'));
$this->app->redirect('index.php');
}
// Check if the user is authorized to do this.
if (!JFactory::getUser()->authorise('core.admin')) {
$this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'));
$this->app->redirect('index.php');
}
// Set FTP credentials, if given.
JClientHelper::setCredentialsFromRequest('ftp');
$model = new ConfigModelApplication();
$data = $this->input->post->get('jform', array(), 'array');
// Complete data array if needed
$oldData = $model->getData();
$data = array_replace($oldData, $data);
// Get request type
$saveFormat = JFactory::getDocument()->getType();
// Handle service requests
if ($saveFormat == 'json') {
return $model->save($data);
}
// Must load after serving service-requests
$form = $model->getForm();
// Validate the posted data.
$return = $model->validate($form, $data);
// Check for validation errors.
if ($return === false) {
/*
* The validate method enqueued all messages for us, so we just need to redirect back.
*/
// Save the data in the session.
$this->app->setUserState('com_config.config.global.data', $data);
// Redirect back to the edit screen.
$this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.application', false));
}
// Attempt to save the configuration.
$data = $return;
$return = $model->save($data);
// Check the return value.
if ($return === false) {
/*
* The save method enqueued all messages for us, so we just need to redirect back.
*/
// Save the data in the session.
$this->app->setUserState('com_config.config.global.data', $data);
// Save failed, go back to the screen and display a notice.
$this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.application', false));
}
// Set the success message.
$this->app->enqueueMessage(JText::_('COM_CONFIG_SAVE_SUCCESS'));
// Set the redirect based on the task.
switch ($this->options[3]) {
case 'apply':
$this->app->redirect(JRoute::_('index.php?option=com_config', false));
break;
case 'save':
default:
$this->app->redirect(JRoute::_('index.php', false));
break;
}
}