本文整理汇总了PHP中JFactory::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP JFactory::getUser方法的具体用法?PHP JFactory::getUser怎么用?PHP JFactory::getUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFactory
的用法示例。
在下文中一共展示了JFactory::getUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* Generates a list of JSON items.
*
* @return void
*/
public function display($tpl = null)
{
$model = $this->getModel();
$this->item = $this->get('Item');
$this->component = $model->getState($model->getName() . '.component');
$this->section = $model->getState($model->getName() . '.section');
$this->asset_id = $model->getState($model->getName() . '.asset_id');
$this->project_id = $model->getState($model->getName() . '.project_id');
$this->inherit = $model->getState($model->getName() . '.inherit');
if (!$this->asset_id && $this->inherit) {
$this->asset_id = $this->getComponentProjectAssetId($this->component, $this->project_id);
}
$this->rules = $this->getAssetRules();
$this->public_groups = array('1', JComponentHelper::getParams('com_users')->get('guest_usergroup', 1));
$user = JFactory::getUser();
if (!$user->authorise('core.admin', $this->component) && !$user->authorise('core.manage', $this->component)) {
JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
return false;
}
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseWarning(500, implode("\n", $errors));
return false;
}
parent::display($tpl);
}
示例2: addToolbar
/**
* Add the page title and toolbar.
*/
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu', true);
$user = JFactory::getUser();
$isNew = $this->item->id == 0;
if (isset($this->item->checked_out)) {
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
} else {
$checkedOut = false;
}
$canDo = SomosmaestrosHelper::getActions();
JToolBarHelper::title(JText::_('COM_SOMOSMAESTROS_TITLE_FORMACION'), 'formacion.png');
// If not checked out, can save the item.
if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) {
JToolBarHelper::apply('formacion.apply', 'JTOOLBAR_APPLY');
JToolBarHelper::save('formacion.save', 'JTOOLBAR_SAVE');
}
if (!$checkedOut && $canDo->get('core.create')) {
JToolBarHelper::custom('formacion.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
}
// If an existing item, can save to a copy.
if (!$isNew && $canDo->get('core.create')) {
JToolBarHelper::custom('formacion.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
}
if (empty($this->item->id)) {
JToolBarHelper::cancel('formacion.cancel', 'JTOOLBAR_CANCEL');
} else {
JToolBarHelper::cancel('formacion.cancel', 'JTOOLBAR_CLOSE');
}
}
示例3: store
public function store($updateNulls = false)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
// Attempt to store the user data.
return parent::store($updateNulls);
}
示例4: akeebaACLCheck
/**
* Do our custom ACL checks for the back-end views
*
* @return boolean
*/
private function akeebaACLCheck()
{
// Get the view
$view = $this->input->getCmd('view', '');
// Fetch the privilege to check, or use the default (akeeba.configure)
// privilege.
if (array_key_exists($view, self::$viewACLMap)) {
$privilege = self::$viewACLMap[$view];
} else {
$privilege = 'akeeba.configure';
}
// If an empty privileve is defined do not do any ACL check
if (empty($privilege)) {
return true;
}
// Throw an error if we are not allowed access to the view
if (!JFactory::getUser()->authorise($privilege, 'com_akeeba')) {
$this->setRedirect('index.php?option=com_akeeba&view=cpanel');
JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
$this->redirect();
return false;
} else {
return true;
}
}
示例5: display
/**
* sauto view display method.
*
* @param string $tpl The name of the template file to parse;
*
* @return void
*/
public function display($tpl = null)
{
$app =& JFactory::getApplication();
$link_redirect = JRoute::_('index.php?option=com_sauto');
$user =& JFactory::getUser();
$uid = $user->id;
if ($uid == 0) {
//vizitator
$app->redirect($link_redirect, JText::_('SAUTO_PAGE_NOT_EXIST'));
} else {
$db = JFactory::getDbo();
$query = "SELECT `tip_cont` FROM #__sa_profiles WHERE `uid` = '" . $uid . "'";
$db->setQuery($query);
$type = $db->loadResult();
if ($type == 0) {
//cont customer
$tpl = '0';
} elseif ($type == 1) {
//cont dealer
$tpl = '1';
} else {
$app->redirect($link_redirect, JText::_('SAUTO_PAGE_NOT_EXIST'));
}
parent::display($tpl);
}
}
示例6: addToolbar
/**
* Add the page title and toolbar.
*/
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu', true);
$user = JFactory::getUser();
$isNew = $this->item->id == 0;
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
$canDo = SibdietHelper::getActions();
JToolBarHelper::title(JText::_('COM_SIBDIET_MANAGER_ERRAND'), 'database errands');
// If not checked out, can save the item.
if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) {
JToolBarHelper::apply('errand.apply');
JToolBarHelper::save('errand.save');
}
if (!$checkedOut && $canDo->get('core.create')) {
JToolbarHelper::save2new('errand.save2new');
}
// If an existing item, can save to a copy.
if (!$isNew && $canDo->get('core.create')) {
JToolbarHelper::save2copy('errand.save2copy');
}
if (empty($this->item->id)) {
JToolBarHelper::cancel('errand.cancel');
} else {
JToolBarHelper::cancel('errand.cancel', 'JTOOLBAR_CLOSE');
}
}
示例7: getInput
protected function getInput()
{
$this->params = $this->element->attributes();
JHtml::stylesheet('nnframework/style.min.css', false, true);
$title = $this->get('label');
$description = $this->get('description');
$class = $this->get('class');
$showclose = $this->get('showclose', 0);
$start = $this->get('start', 0);
$end = $this->get('end', 0);
$html = array();
if ($start || !$end) {
$html[] = '</div>';
if (strpos($class, 'alert') !== false) {
$html[] = '<div class="alert ' . $class . '">';
} else {
$html[] = '<div class="well well-small ' . $class . '">';
}
if ($showclose && JFactory::getUser()->authorise('core.admin')) {
$html[] = '<button type="button" class="close nn_remove_assignment">×</button>';
}
if ($title) {
$html[] = '<h4>' . $this->prepareText($title) . '</h4>';
}
if ($description) {
$html[] = '<div>' . $this->prepareText($description) . '</div>';
}
$html[] = '<div><div>';
}
if (!$start && !$end) {
$html[] = '</div>';
}
return '</div>' . implode('', $html);
}
示例8: addToolbar
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu', true);
$user = JFactory::getUser();
$isNew = $this->item->id == 0;
$checkedOut = !true;
// Since we don't track these assets at the item level, use the category id.
JToolbarHelper::title(JText::_('COM_HTRAININGLOGS_MANAGER_H_TR_SESSION'), 'link h_tr_sessions');
// If not checked out, can save the item.
if (!$checkedOut || count($user->getAuthorisedCategories('com_htraininglogs', 'core.create'))) {
JToolbarHelper::apply('h_tr_session.apply');
JToolbarHelper::save('h_tr_session.save');
}
if (!$checkedOut && count($user->getAuthorisedCategories('com_htraininglogs', 'core.create'))) {
JToolbarHelper::save2new('h_tr_session.save2new');
}
// If an existing item, can save to a copy.
if (!$isNew && count($user->getAuthorisedCategories('com_htraininglogs', 'core.create')) > 0) {
JToolbarHelper::save2copy('h_tr_session.save2copy');
}
if (empty($this->item->id)) {
JToolbarHelper::cancel('h_tr_session.cancel');
} else {
if ($this->state->params->get('save_history', 0) && $user->authorise('core.edit')) {
JToolbarHelper::versions('com_htraininglogs.h_tr_session', $this->item->id);
}
JToolbarHelper::cancel('h_tr_session.cancel', 'JTOOLBAR_CLOSE');
}
JToolbarHelper::divider();
JToolbarHelper::help('JHELP_COMPONENTS_H_tr_sessionS_LINKS_EDIT');
}
示例9: addToolbar
/**
* Add the page title and toolbar.
*/
protected function addToolbar()
{
$canDo = JfoobarsHelper::getActions($this->state->get('filter.category_id'));
$user = JFactory::getUser();
JToolBarHelper::title(JText::_('COM_JFOOBARS_JFOOBARS_TITLE'), 'jfoobar.png');
if ($canDo->get('core.create') || count($user->getAuthorisedCategories('com_jfoobars', 'core.create')) > 0) {
JToolBarHelper::addNew('jfoobar.add');
}
if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) {
JToolBarHelper::editList('jfoobar.edit');
}
if ($canDo->get('core.edit.state')) {
JToolBarHelper::divider();
JToolBarHelper::publish('jfoobars.publish', 'JTOOLBAR_PUBLISH', true);
JToolBarHelper::unpublish('jfoobars.unpublish', 'JTOOLBAR_UNPUBLISH', true);
JToolBarHelper::divider();
JToolBarHelper::checkin('jfoobars.checkin');
}
if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
JToolBarHelper::deleteList('', 'jfoobars.delete', 'JTOOLBAR_EMPTY_TRASH');
JToolBarHelper::divider();
} else {
if ($canDo->get('core.edit.state')) {
JToolBarHelper::trash('jfoobars.trash');
JToolBarHelper::divider();
}
}
if ($canDo->get('core.admin')) {
JToolBarHelper::preferences('com_jfoobars');
JToolBarHelper::divider();
}
}
示例10: getContact
/**
* Gets a list of contacts
* @param array
* @return mixed Object or null
*/
function getContact($pk = null)
{
$query = $this->_getContactQuery($pk);
try {
$this->_db->setQuery($query);
$result = $this->_db->loadObject();
if ($error = $this->_db->getErrorMsg()) {
throw new Exception($error);
}
if (empty($result)) {
throw new Exception(JText::_('Contact_Error_Contact_not_found'), 404);
}
// Convert parameter fields to object and merge with menu item params
$registry = new JRegistry();
$registry->loadJSON($result->params);
$result->mergedParams = clone $this->getState('params');
$result->mergedParams->merge($registry);
} catch (Exception $e) {
$this->setError($e);
return false;
}
if ($result) {
$user =& JFactory::getUser();
$groups = implode(',', $user->authorisedLevels());
//get the content by the linked user
$query = 'SELECT id, title, state, access, created' . ' FROM #__content' . ' WHERE created_by = ' . (int) $result->user_id . ' AND access IN (' . $groups . ')' . ' ORDER BY state DESC, created DESC';
$this->_db->setQuery($query, 0, 10);
$articles = $this->_db->loadObjectList();
$contact->articles = $articles;
}
return $result;
}
示例11: addToolbar
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu', true);
$user = JFactory::getUser();
$isNew = $this->item->id == 0;
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
// Built the actions for new and existing records.
$canDo = JHelperContent::getActions('com_testyourself');
JToolBarHelper::title(JText::_('COM_TESTYOURSELF_MANAGER_QUESTION'), 'question questions');
// If not checked out, can save the item.
if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) {
JToolBarHelper::apply('question.apply');
JToolBarHelper::save('question.save');
}
if (!$checkedOut && $canDo->get('core.create')) {
JToolbarHelper::save2new('question.save2new');
}
// If an existing item, can save to a copy.
if (!$isNew && $canDo->get('core.create')) {
JToolbarHelper::save2copy('question.save2copy');
}
if (empty($this->item->id)) {
JToolBarHelper::cancel('question.cancel');
} else {
JToolBarHelper::cancel('question.cancel', 'JTOOLBAR_CLOSE');
}
}
示例12: getListQuery
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$user = JFactory::getUser();
// Select the required fields from the table.
$query->select($this->getState('list.select', 'a.*, ' . 'u.name AS user_from'));
$query->from('#__messages AS a');
// Join over the users for message owner.
$query->join('INNER', '#__users AS u ON u.id = a.user_id_from');
$query->where('a.user_id_to = ' . (int) $user->get('id'));
// Filter by published state.
$state = $this->getState('filter.state');
if (is_numeric($state)) {
$query->where('a.state = ' . (int) $state);
} elseif ($state === '') {
$query->where('(a.state IN (0, 1))');
}
// Filter by search in subject or message.
$search = $this->getState('filter.search');
if (!empty($search)) {
$search = $db->Quote('%' . $db->escape($search, true) . '%', false);
$query->where('a.subject LIKE ' . $search . ' OR a.message LIKE ' . $search);
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering', 'a.date_time')) . ' ' . $db->escape($this->getState('list.direction', 'DESC')));
//echo nl2br(str_replace('#__','jos_',$query));
return $query;
}
示例13: addToolbar
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
JRequest::setVar('hidemainmenu', true);
$user = JFactory::getUser();
$isNew = $this->item->id == 0;
$canDo = MenusHelper::getActions($this->state->get('filter.parent_id'));
JToolBarHelper::title(JText::_($isNew ? 'COM_MENUS_VIEW_NEW_MENU_TITLE' : 'COM_MENUS_VIEW_EDIT_MENU_TITLE'), 'menu.png');
// If a new item, can save the item. Allow users with edit permissions to apply changes to prevent returning to grid.
if ($isNew && $canDo->get('core.create')) {
if ($canDo->get('core.edit')) {
JToolBarHelper::apply('menu.apply');
}
JToolBarHelper::save('menu.save');
}
// If user can edit, can save the item.
if (!$isNew && $canDo->get('core.edit')) {
JToolBarHelper::apply('menu.apply');
JToolBarHelper::save('menu.save');
}
// If the user can create new items, allow them to see Save & New
if ($canDo->get('core.create')) {
JToolBarHelper::save2new('menu.save2new');
}
if ($isNew) {
JToolBarHelper::cancel('menu.cancel');
} else {
JToolBarHelper::cancel('menu.cancel', 'JTOOLBAR_CLOSE');
}
JToolBarHelper::divider();
JToolBarHelper::help('JHELP_MENUS_MENU_MANAGER_EDIT');
}
示例14: array
/**
* Helper method to return button list.
*
* This method returns the array by reference so it can be
* used to add custom buttons or remove default ones.
*
* @param JRegistry The module parameters.
*
* @return array An array of buttons
* @since 1.6
*/
public static function &getButtons($params)
{
$key = (string) $params;
if (!isset(self::$buttons[$key])) {
$context = $params->get('context', 'mod_quickicon');
if ($context == 'mod_quickicon') {
// Load mod_quickicon language file in case this method is called before rendering the module
JFactory::getLanguage()->load('mod_quickicon');
self::$buttons[$key] = array(array('link' => JRoute::_('index.php?option=com_content&task=article.add'), 'image' => 'header/icon-48-article-add.png', 'text' => JText::_('MOD_QUICKICON_ADD_NEW_ARTICLE'), 'access' => array('core.manage', 'com_content', 'core.create', 'com_content')), array('link' => JRoute::_('index.php?option=com_content'), 'image' => 'header/icon-48-article.png', 'text' => JText::_('MOD_QUICKICON_ARTICLE_MANAGER'), 'access' => array('core.manage', 'com_content')), array('link' => JRoute::_('index.php?option=com_categories&extension=com_content'), 'image' => 'header/icon-48-category.png', 'text' => JText::_('MOD_QUICKICON_CATEGORY_MANAGER'), 'access' => array('core.manage', 'com_content')), array('link' => JRoute::_('index.php?option=com_media'), 'image' => 'header/icon-48-media.png', 'text' => JText::_('MOD_QUICKICON_MEDIA_MANAGER'), 'access' => array('core.manage', 'com_media')), array('link' => JRoute::_('index.php?option=com_menus'), 'image' => 'header/icon-48-menumgr.png', 'text' => JText::_('MOD_QUICKICON_MENU_MANAGER'), 'access' => array('core.manage', 'com_menus')), array('link' => JRoute::_('index.php?option=com_users'), 'image' => 'header/icon-48-user.png', 'text' => JText::_('MOD_QUICKICON_USER_MANAGER'), 'access' => array('core.manage', 'com_users')), array('link' => JRoute::_('index.php?option=com_modules'), 'image' => 'header/icon-48-module.png', 'text' => JText::_('MOD_QUICKICON_MODULE_MANAGER'), 'access' => array('core.manage', 'com_modules')), array('link' => JRoute::_('index.php?option=com_installer'), 'image' => 'header/icon-48-extension.png', 'text' => JText::_('MOD_QUICKICON_EXTENSION_MANAGER'), 'access' => array('core.manage', 'com_installer')), array('link' => JRoute::_('index.php?option=com_languages'), 'image' => 'header/icon-48-language.png', 'text' => JText::_('MOD_QUICKICON_LANGUAGE_MANAGER'), 'access' => array('core.manage', 'com_languages')), array('link' => JRoute::_('index.php?option=com_config'), 'image' => 'header/icon-48-config.png', 'text' => JText::_('MOD_QUICKICON_GLOBAL_CONFIGURATION'), 'access' => array('core.manage', 'com_config', 'core.admin', 'com_config')), array('link' => JRoute::_('index.php?option=com_templates'), 'image' => 'header/icon-48-themes.png', 'text' => JText::_('MOD_QUICKICON_TEMPLATE_MANAGER'), 'access' => array('core.manage', 'com_templates')), array('link' => JRoute::_('index.php?option=com_admin&task=profile.edit&id=' . JFactory::getUser()->id), 'image' => 'header/icon-48-user-profile.png', 'text' => JText::_('MOD_QUICKICON_PROFILE'), 'access' => true));
} else {
self::$buttons[$key] = array();
}
// Include buttons defined by published quickicon plugins
JPluginHelper::importPlugin('quickicon');
$app = JFactory::getApplication();
$arrays = (array) $app->triggerEvent('onGetIcons', array($context));
foreach ($arrays as $response) {
foreach ($response as $icon) {
$default = array('link' => null, 'image' => 'header/icon-48-config.png', 'text' => null, 'access' => true);
$icon = array_merge($default, $icon);
if (!is_null($icon['link']) && !is_null($icon['text'])) {
self::$buttons[$key][] = $icon;
}
}
}
}
return self::$buttons[$key];
}
示例15: addToolbar
/**
* Add the page title and toolbar.
*
*
*/
protected function addToolbar()
{
require_once JPATH_COMPONENT . '/helpers/jdownloadshelper.php';
JRequest::setVar('hidemainmenu', true);
$user = JFactory::getUser();
$isNew = $this->item->id == 0;
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
$canDo = JDownloadsHelper::getActions();
$document = JFactory::getDocument();
$document->addStyleSheet('components/com_jdownloads/assets/css/style.css');
$title = $isNew ? JText::_('COM_JDOWNLOADS_LICEDIT_ADD') : JText::_('COM_JDOWNLOADS_LICEDIT_EDIT');
JToolBarHelper::title(JText::_('COM_JDOWNLOADS') . ': ' . $title, 'jdlicenses');
// If not checked out, can save the item.
if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) {
JToolBarHelper::apply('license.apply');
JToolBarHelper::save('license.save');
}
if (!$checkedOut && $canDo->get('core.create')) {
JToolBarHelper::save2new('license.save2new');
}
// If an existing item, can save to a copy.
if (!$isNew && $canDo->get('core.create')) {
JToolBarHelper::save2copy('license.save2copy');
}
if (empty($this->item->id)) {
JToolBarHelper::cancel('license.cancel');
} else {
JToolBarHelper::cancel('license.cancel', 'JTOOLBAR_CLOSE');
}
JToolBarHelper::divider();
JToolBarHelper::help('help.license', true);
}