-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Task #162657 chore: Public access to UCM list and Item view #368
Open
KishoriBKarale
wants to merge
2
commits into
techjoomla:release-1.2.4
Choose a base branch
from
KishoriBKarale:publicPermission
base: release-1.2.4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,10 @@ | |
defined('_JEXEC') or die; | ||
|
||
jimport('joomla.application.component.view'); | ||
use Joomla\CMS\Factory; | ||
use Joomla\CMS\Language\Text; | ||
use Joomla\CMS\Uri\Uri; | ||
use Joomla\CMS\Router\Route; | ||
|
||
/** | ||
* View to edit | ||
|
@@ -39,27 +43,33 @@ class TjucmViewItem extends JViewLegacy | |
*/ | ||
public function display($tpl = null) | ||
{ | ||
$app = JFactory::getApplication(); | ||
|
||
if (!JFactory::getUser()->id) | ||
{ | ||
$msg = JText::_('COM_TJUCM_LOGIN_MSG'); | ||
|
||
// Get current url. | ||
$current = JUri::getInstance()->toString(); | ||
$url = base64_encode($current); | ||
JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $url, false), $msg); | ||
} | ||
$app = Factory::getApplication(); | ||
$user = Factory::getUser(); | ||
|
||
// Load tj-fields language file | ||
$lang = JFactory::getLanguage(); | ||
$lang = Factory::getLanguage(); | ||
$lang->load('com_tjfields', JPATH_SITE); | ||
|
||
$this->state = $this->get('State'); | ||
$this->item = $this->get('Data'); | ||
$model = $this->getModel("Item"); | ||
$this->model = $this->getModel("Item"); | ||
$this->params = $app->getParams('com_tjucm'); | ||
$this->ucmTypeId = $model->getState('ucmType.id'); | ||
|
||
if (!$user->id) | ||
{ | ||
// Check public user permission for view all items | ||
if (empty($user->authorise('core.type.viewitem', 'com_tjucm.type.' . $this->ucmTypeId))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @KishoriBKarale Use TjucmAccess class to check ACL and permission |
||
{ | ||
$msg = Text::_('COM_TJUCM_LOGIN_MSG'); | ||
|
||
// Get current url. | ||
$current = Uri::getInstance()->toString(); | ||
$url = base64_encode($current); | ||
$app->redirect(Route::_('index.php?option=com_users&view=login&return=' . $url, false), $msg); | ||
} | ||
} | ||
|
||
// Load tj-fields helper helper | ||
$path = JPATH_SITE . '/components/com_tjfields/helpers/tjfields.php'; | ||
|
@@ -71,7 +81,6 @@ public function display($tpl = null) | |
} | ||
|
||
$this->tjFieldsHelper = new TjfieldsHelper; | ||
$this->ucmTypeId = $model->getState('ucmType.id'); | ||
|
||
// Check the view access to the article (the model has already computed the values). | ||
if ($this->item->params->get('access-view') == false) | ||
|
@@ -118,7 +127,7 @@ public function display($tpl = null) | |
"clientComponent" => 'com_tjucm', | ||
"client" => $this->client, | ||
"view" => $view[1], | ||
"layout" => 'edit', | ||
"layout" => 'default', | ||
"content_id" => $this->id) | ||
); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,9 @@ | |
defined('_JEXEC') or die; | ||
|
||
jimport('joomla.application.component.view'); | ||
use Joomla\CMS\Factory; | ||
use Joomla\CMS\Uri\Uri; | ||
use Joomla\CMS\Language\Text; | ||
|
||
/** | ||
* View class for a list of Tjucm. | ||
|
@@ -65,27 +68,8 @@ class TjucmViewItems extends JViewLegacy | |
*/ | ||
public function display($tpl = null) | ||
{ | ||
$app = JFactory::getApplication(); | ||
$user = JFactory::getUser(); | ||
|
||
if (!$user->id) | ||
{ | ||
$msg = JText::_('COM_TJUCM_LOGIN_MSG'); | ||
|
||
// Get current url. | ||
$current = JUri::getInstance()->toString(); | ||
$url = base64_encode($current); | ||
JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $url, false), $msg); | ||
} | ||
|
||
// Check the view access to the items. | ||
if (!$user->id) | ||
{ | ||
$app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error'); | ||
$app->setHeader('status', 403, true); | ||
|
||
return false; | ||
} | ||
$app = Factory::getApplication(); | ||
$user = Factory::getUser(); | ||
|
||
$this->state = $this->get('State'); | ||
$this->items = $this->get('Items'); | ||
|
@@ -100,6 +84,34 @@ public function display($tpl = null) | |
$this->canImport = TjucmAccess::canImport($this->ucmTypeId); | ||
$this->draft = array("" => JText::_('COM_TJUCM_DATA_STATUS_SELECT_OPTION'), | ||
"0" => JText::_("COM_TJUCM_DATA_STATUS_SAVE"), "1" => JText::_('COM_TJUCM_DATA_STATUS_DRAFT')); | ||
|
||
if (!$user->id) | ||
{ | ||
// Check public user permission for view all items | ||
if (empty($user->authorise('core.type.viewitem', 'com_tjucm.type.' . $this->ucmTypeId))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @KishoriBKarale Check the same as mentioned in the above comments |
||
{ | ||
$msg = Text::_('COM_TJUCM_LOGIN_MSG'); | ||
|
||
// Get current url. | ||
$current = Uri::getInstance()->toString(); | ||
$url = base64_encode($current); | ||
$app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $url, false), $msg); | ||
} | ||
} | ||
|
||
// Check the view access to the items. | ||
if (!$user->id) | ||
{ | ||
// Check public user permission for view all items | ||
if (empty($user->authorise('core.type.viewitem', 'com_tjucm.type.' . $this->ucmTypeId))) | ||
{ | ||
$app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'error'); | ||
$app->setHeader('status', 403, true); | ||
|
||
return false; | ||
} | ||
} | ||
|
||
// If did not get the client from url then get if from menu param | ||
if (empty($this->client)) | ||
{ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KishoriBKarale Do we need to check this especially for public users?
We can check if any kind of user has access to the page.