Commit 606c30df authored by Julien Vonthron's avatar Julien Vonthron
Browse files

working on fixing acl madness

parent 865c5408
......@@ -33,7 +33,7 @@ class JoomleagueViewMatches extends JLGView
$division = $app->getUserStateFromRequest($option.'mc_division', 'division', '', 'string');
$project_id = $app->getUserState( $option . 'project' );
$search = JString::strtolower($search);
$round_id = $jinput->get('rid',array(),'array');
JArrayHelper::toInteger($round_id);
if(empty($round_id))
......@@ -48,12 +48,12 @@ class JoomleagueViewMatches extends JLGView
$mdlRound = JModelLegacy::getInstance('round','JoomleagueModel');
$round = $mdlRound->getItem($round_id);
$matches = $this->get('Data');
$matches = $this->get('Data');
$total = $this->get('Total');
$pagination = $this->get('Pagination');
$model = $this->getModel();
$projectteams = $model->getProjectTeams();
// state filter
$lists['state'] = JoomleagueHelper::stateOptions($filter_state,true,true,false,false);
......@@ -64,7 +64,7 @@ class JoomleagueViewMatches extends JLGView
// search filter
$lists['search']=$search;
$lists['search_mode']=$search_mode;
//build the html options for teams
foreach ($matches as $row)
{
......@@ -87,9 +87,9 @@ class JoomleagueViewMatches extends JLGView
// build the html selectlist for rounds
$mdlProject = JModelLegacy::getInstance('project','JoomleagueModel');
$project = $mdlProject->getItem($project_id);
$ress = JoomleagueHelper::getRoundsOptions($project_id, 'ASC', true);
$project_roundslist = array();
foreach ($ress as $res)
......@@ -169,7 +169,7 @@ class JoomleagueViewMatches extends JLGView
}
$lists['divisions']=$divisions;
unset($divisions);
$this->division=$division;
$this->user=JFactory::getUser();
$this->lists=$lists;
......@@ -181,7 +181,7 @@ class JoomleagueViewMatches extends JLGView
$this->teams=$projectteams;
$this->request_url=$uri->toString();
$this->prefill=$params->get('use_prefilled_match_roster',0);
$this->addToolbar();
parent::display($tpl);
}
......@@ -192,6 +192,7 @@ class JoomleagueViewMatches extends JLGView
protected function addToolbar()
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
$jinput = $app->input;
$massadd = $jinput->getInt('massadd',0);
......@@ -200,27 +201,42 @@ class JoomleagueViewMatches extends JLGView
if (!$massadd)
{
JLToolBarHelper::publishList('matches.publish');
JLToolBarHelper::unpublishList('matches.unpublish');
JToolBarHelper::divider();
if ($user->authorise('core.edit.state', 'com_joomleague'))
{
JToolBarHelper::publishList('matches.publish');
JToolBarHelper::unpublishList('matches.unpublish');
JToolBarHelper::divider();
}
JLToolBarHelper::apply('matches.saveshort');
JToolBarHelper::divider();
if ($user->authorise('core.edit', 'com_joomleague'))
{
JToolBarHelper::apply('matches.saveshort');
JToolBarHelper::divider();
}
if ($user->authorise('core.create', 'com_joomleague'))
{
JToolBarHelper::custom('matches.massadd', 'new.png', 'new_f2.png', 'COM_JOOMLEAGUE_ADMIN_MATCHES_MASSADD_MATCHES', false);
JToolBarHelper::addNew('match.addmatch', 'COM_JOOMLEAGUE_ADMIN_MATCHES_MASSADD_ADD_MATCH');
}
if ($user->authorise('core.delete', 'com_joomleague'))
{
JToolBarHelper::deleteList(JText::_('COM_JOOMLEAGUE_ADMIN_MATCHES_MASSADD_WARNING'), 'matches.remove');
}
JLToolBarHelper::custom('matches.massadd','new.png','new_f2.png','COM_JOOMLEAGUE_ADMIN_MATCHES_MASSADD_MATCHES',false);
JLToolBarHelper::addNewX('match.addmatch','COM_JOOMLEAGUE_ADMIN_MATCHES_MASSADD_ADD_MATCH');
JLToolBarHelper::deleteList(JText::_('COM_JOOMLEAGUE_ADMIN_MATCHES_MASSADD_WARNING'), 'matches.remove');
JToolBarHelper::divider();
JToolBarHelper::back('Back','index.php?option=com_joomleague&view=rounds');
}
else
{
JLToolBarHelper::custom('matches.cancelmassadd','cancel.png','cancel_f2.png','COM_JOOMLEAGUE_ADMIN_MATCHES_MASSADD_CANCEL_MATCHADD',false);
JToolBarHelper::custom('matches.cancelmassadd','cancel.png','cancel_f2.png','COM_JOOMLEAGUE_ADMIN_MATCHES_MASSADD_CANCEL_MATCHADD',false);
}
JToolBarHelper::help('screen.joomleague',true);
}
private function getRoundDescription($round)
{
$first = new DateTime($round->round_date_first);
......
......@@ -62,8 +62,10 @@ class JoomleagueViewProject extends JLGView
$isNew = ($this->item->id == 0);
$checkedOut = ! ($this->item->checked_out == 0 || $this->item->checked_out == $userId);
$canDo = JHelperContent::getActions('com_joomleague');
// Set toolbar items for the page
if($this->copy)
if ($this->copy)
{
$toolbarTitle = JText::_('COM_JOOMLEAGUE_ADMIN_PROJECT_COPY_PROJECT');
}
......@@ -73,26 +75,30 @@ class JoomleagueViewProject extends JLGView
$this->form->getValue('name');
JToolBarHelper::divider();
}
JToolBarHelper::title($toolbarTitle,'jl-ProjectSettings');
if(!$this->copy)
if ($this->copy)
{
JLToolBarHelper::apply('project.apply');
JLToolBarHelper::save('project.save');
JToolBarHelper::save('project.copysave');
}
else
elseif ($canDo->get('core.create') || $canDo->get('core.edit'))
{
JLToolBarHelper::save('project.copysave');
JToolBarHelper::apply('project.apply');
JToolBarHelper::save('project.save');
}
JToolBarHelper::divider();
if((!$this->edit) || ($this->copy))
{
JLToolBarHelper::cancel('project.cancel');
JToolBarHelper::cancel('project.cancel');
}
else
{
JLToolBarHelper::cancel('project.cancel','COM_JOOMLEAGUE_GLOBAL_CLOSE');
JToolBarHelper::cancel('project.cancel','COM_JOOMLEAGUE_GLOBAL_CLOSE');
}
JToolBarHelper::help('screen.joomleague',true);
}
}
......@@ -93,20 +93,43 @@ class JoomleagueViewProjects extends JLGView
{
// Set toolbar items for the page
JToolBarHelper::title(JText::_('COM_JOOMLEAGUE_ADMIN_PROJECTS_TITLE'),'jl-ProjectSettings');
JLToolBarHelper::addNew('project.add');
JLToolBarHelper::custom('projects.copy','copy.png','copy_f2.png','COM_JOOMLEAGUE_GLOBAL_COPY',false);
JToolBarHelper::divider();
JLToolBarHelper::publishList('projects.publish');
JLToolBarHelper::unpublishList('projects.unpublish');
JToolBarHelper::divider();
JLToolBarHelper::custom('projects.import','upload','upload','COM_JOOMLEAGUE_GLOBAL_CSV_IMPORT',false);
JLToolBarHelper::archiveList('projects.export','COM_JOOMLEAGUE_GLOBAL_XML_EXPORT');
JToolBarHelper::divider();
JLToolBarHelper::archiveList('projects.archive');
JLToolBarHelper::trash('projects.trash');
JLToolBarHelper::deleteList('COM_JOOMLEAGUE_ADMIN_PROJECTS_DELETE_WARNING','projects.remove');
$canDo = JHelperContent::getActions('com_joomleague');
if ($canDo->get('core.create'))
{
JToolBarHelper::addNew('project.add');
JToolBarHelper::custom('projects.copy','copy.png','copy_f2.png','COM_JOOMLEAGUE_GLOBAL_COPY',false);
JToolBarHelper::divider();
}
if ($canDo->get('core.edit.state'))
{
JToolBarHelper::publishList('projects.publish');
JToolBarHelper::unpublishList('projects.unpublish');
JToolBarHelper::divider();
}
if ($canDo->get('core.create'))
{
JToolBarHelper::custom('projects.import', 'upload', 'upload', 'COM_JOOMLEAGUE_GLOBAL_CSV_IMPORT', false);
}
JToolBarHelper::archiveList('projects.export', 'COM_JOOMLEAGUE_GLOBAL_XML_EXPORT');
JToolBarHelper::divider();
if ($canDo->get('core.edit.state'))
{
JToolBarHelper::archiveList('projects.archive');
JToolBarHelper::trash('projects.trash');
}
if ($canDo->get('core.delete'))
{
JToolBarHelper::deleteList('COM_JOOMLEAGUE_ADMIN_PROJECTS_DELETE_WARNING','projects.remove');
}
JToolBarHelper::divider();
JToolBarHelper::help('screen.joomleague',true);
}
......
......@@ -43,7 +43,7 @@ class JoomleagueViewRounds extends JLGView
$url = $uri->toString();
$project_id = $app->getUserState($option.'project');
$params = JComponentHelper::getParams($option);
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
......@@ -86,18 +86,18 @@ class JoomleagueViewRounds extends JLGView
$filter_order = $app->getUserStateFromRequest($this->get('context').'.filter_order','filter_order','a.match_number','cmd');
$filter_order_Dir = $app->getUserStateFromRequest($this->get('context').'.filter_order_Dir','filter_order_Dir','','word');
// table ordering
$lists['order_Dir'] = $filter_order_Dir;
$lists['order'] = $filter_order;
$this->massadd = $massadd;
$this->countProjectTeams = count($projectteams);
$this->lists = $lists;
$this->project = $project;
$this->request_url = $url;
$this->params = $params;
$populate = 0;
$this->populate = $populate;
......@@ -155,8 +155,8 @@ class JoomleagueViewRounds extends JLGView
$options[] = JHtml::_('select.option', $t->projectteam_id, $t->text);
}
$lists['teamsorder'] = JHtml::_('select.genericlist', $options, 'teamsorder[]', 'multiple="multiple" size="20"');
$this->project = $project;
$this->request_url = $url;
$this->lists = $lists;
......@@ -171,30 +171,53 @@ class JoomleagueViewRounds extends JLGView
*/
protected function addToolbar()
{
$user = JFactory::getUser();
// Set toolbar items for the page
JToolBarHelper::title(JText::_('COM_JOOMLEAGUE_ADMIN_ROUNDS_TITLE'),'jl-Matchdays');
if(!$this->massadd)
{
JLToolBarHelper::addNew('rounds.quickAdd');
JLToolBarHelper::apply('rounds.saveshort');
if ($user->authorise('core.create', 'com_joomleague'))
{
JToolBarHelper::addNew('rounds.quickAdd');
}
if ($user->authorise('core.edit', 'com_joomleague'))
{
JToolBarHelper::apply('rounds.saveshort');
}
JToolBarHelper::divider();
JLToolBarHelper::custom('rounds.massadd','new.png','new_f2.png','COM_JOOMLEAGUE_ADMIN_ROUNDS_MASSADD_BUTTON',false);
$teams = $this->get('projectteams');
if($teams && count($teams) > 0)
if ($user->authorise('core.create', 'com_joomleague'))
{
JLToolBarHelper::addNew('rounds.populate','COM_JOOMLEAGUE_ADMIN_ROUNDS_POPULATE_BUTTON',false);
JToolBarHelper::custom('rounds.massadd', 'new.png', 'new_f2.png', 'COM_JOOMLEAGUE_ADMIN_ROUNDS_MASSADD_BUTTON', false);
$teams = $this->get('projectteams');
if ($teams && count($teams) > 0)
{
JToolBarHelper::addNew('rounds.populate', 'COM_JOOMLEAGUE_ADMIN_ROUNDS_POPULATE_BUTTON', false);
}
}
JToolBarHelper::divider();
JLToolBarHelper::deleteList(JText::_('COM_JOOMLEAGUE_ADMIN_ROUNDS_DELETE_WARNING'),'rounds.deletematches',
if ($user->authorise('core.delete', 'com_joomleague'))
{
JToolBarHelper::deleteList(JText::_('COM_JOOMLEAGUE_ADMIN_ROUNDS_DELETE_WARNING'), 'rounds.deletematches',
'COM_JOOMLEAGUE_ADMIN_ROUNDS_MASSDEL_BUTTON');
JLToolBarHelper::deleteList(JText::_('COM_JOOMLEAGUE_ADMIN_ROUNDS_DELETE_WARNING'),'rounds.remove');
JToolBarHelper::deleteList(JText::_('COM_JOOMLEAGUE_ADMIN_ROUNDS_DELETE_WARNING'), 'rounds.remove');
}
JToolBarHelper::divider();
}
else
{
JLToolBarHelper::custom('rounds.cancel','cancel.png','cancel_f2.png','COM_JOOMLEAGUE_ADMIN_ROUNDS_MASSADD_CANCEL',false);
JToolBarHelper::custom('rounds.cancel','cancel.png','cancel_f2.png','COM_JOOMLEAGUE_ADMIN_ROUNDS_MASSADD_CANCEL',false);
}
JToolBarHelper::help('screen.joomleague',true);
}
......
......@@ -21,26 +21,26 @@ class JoomleagueViewTeam extends JLGView
{
$app = JFactory::getApplication();
$jinput = $app->input;
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
$extended = $this->getExtended($this->item->extended,'team');
$this->extended = $extended;
// Check for errors.
if(count($errors = $this->get('Errors')))
{
JError::raiseError(500,implode("\n",$errors));
return false;
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*/
......@@ -51,26 +51,28 @@ class JoomleagueViewTeam extends JLGView
$userId = $user->get('id');
$isNew = ($this->item->id == 0);
$checkedOut = ! ($this->item->checked_out == 0 || $this->item->checked_out == $userId);
// Set toolbar items for the page
$text = $isNew ? JText::_('COM_JOOMLEAGUE_GLOBAL_NEW') : JText::_('COM_JOOMLEAGUE_GLOBAL_EDIT') . ': ' . $this->form->getValue('name');
JToolBarHelper::title((JText::_('COM_JOOMLEAGUE_ADMIN_TEAM') . ': <span class="toolbarTitleType">[ ' . $text . ' ]</span>'),'jl-Teams');
if($isNew)
$canDo = JHelperContent::getActions('com_joomleague');
if ($isNew && $canDo->get('core.create'))
{
JLToolBarHelper::apply('team.apply');
JLToolBarHelper::save('team.save');
JToolBarHelper::apply('team.apply');
JToolBarHelper::save('team.save');
JToolBarHelper::divider();
JLToolBarHelper::cancel('team.cancel');
JToolBarHelper::cancel('team.cancel');
}
else
elseif ($canDo->get('core.edit'))
{
JLToolBarHelper::apply('team.apply');
JLToolBarHelper::save('team.save');
JToolBarHelper::apply('team.apply');
JToolBarHelper::save('team.save');
JToolBarHelper::divider();
JLToolBarHelper::cancel('team.cancel','COM_JOOMLEAGUE_GLOBAL_CLOSE');
JToolBarHelper::cancel('team.cancel','COM_JOOMLEAGUE_GLOBAL_CLOSE');
}
JToolBarHelper::help('screen.joomleague.edit');
}
}
......@@ -43,19 +43,34 @@ class JoomleagueViewTeams extends JLGView
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar
*/
protected function addToolbar()
{
{
$canDo = JHelperContent::getActions('com_joomleague');
// Set toolbar items for the page
JToolBarHelper::title(JText::_('COM_JOOMLEAGUE_ADMIN_TEAMS_TITLE'),'jl-Teams');
JLToolBarHelper::addNew('team.add');
JLToolBarHelper::custom('teams.copysave','copy.png','copy_f2.png','COM_JOOMLEAGUE_GLOBAL_COPY',true);
JLToolBarHelper::custom('teams.import','upload','upload','COM_JOOMLEAGUE_GLOBAL_CSV_IMPORT',false);
JLToolBarHelper::archiveList('teams.export','COM_JOOMLEAGUE_GLOBAL_XML_EXPORT');
JLToolBarHelper::deleteList('COM_JOOMLEAGUE_GLOBAL_CONFIRM_DELETE','teams.delete');
if ($canDo->get('core.create'))
{
JToolBarHelper::addNew('team.add');
JToolBarHelper::custom('teams.copysave','copy.png','copy_f2.png','COM_JOOMLEAGUE_GLOBAL_COPY',true);
JToolBarHelper::custom('teams.import','upload','upload','COM_JOOMLEAGUE_GLOBAL_CSV_IMPORT',false);
}
if ($canDo->get('core.delete'))
{
JToolBarHelper::deleteList('COM_JOOMLEAGUE_GLOBAL_CONFIRM_DELETE', 'teams.delete');
}
if ($canDo->get('core.manage'))
{
JToolBarHelper::archiveList('teams.export','COM_JOOMLEAGUE_GLOBAL_XML_EXPORT');
}
JToolBarHelper::divider();
JToolBarHelper::help('screen.joomleague',true);
}
......
......@@ -46,26 +46,3 @@ require_once JLG_PATH_ADMIN.'/tables/jltable.php';
JTable::addIncludePath(JLG_PATH_ADMIN.'/tables');
require_once JLG_PATH_ADMIN.'/helpers/plugins.php';
$app = JFactory::getApplication();
$task = $app->input->get('task');
$option = $app->input->get('option');
if($task != '' && $option == 'com_joomleague') {
if (!JFactory::getUser()->authorise($task, 'com_joomleague')) {
// @todo: should this be visible for the normal user? if not then it can be changed
// display the task which is not handled by the access.xml
$ignoreTask = array(
'clubform.cancel','clubform.edit','clubform.save',
'projectteamform.cancel','projectteamform.edit','projectteamform.save'
);
if (in_array($task, $ignoreTask)) {
// pass as they are handled by the controller
} else {
/* return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR').' Task: ' .$task); */
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment