Dear Alun,

I am using LeagueSite for the new website of the Student Sport Organisation of Wageningen University.
It does what it should do, but i cannot get 1 thing to work.

When you create a team, you can enter a team manager. This user is "allowed to enter results and edit the team (appropriate permissions must be set)".

I think I have all permissions set, but although I can display the node of the match for which this user should enter results, no edit tab is present so no entering of results. Also if enter the URL to the match results page, eg http://localhost/Thymos/node/100/edit/score, then it tells me that this user does not have access to the page.

What am i doing wrong? What are the appropriate permissions for this to work? See attached image for current permissions.

Regards and thanks for any clues,

Onno

Comments

Alun’s picture

Hi Onno, thanks for your post, I am really busy at the moment, and not had time to check this out, but the feature worked for me when I tested it and implemented it, so it should work, as long as the user you are trying to edit with is a "thymosfloorballcaptain"
I will have a look at the code when I can to resolve this.
Thanks
Alun

OnnoRoos’s picture

Dear Alun,

Thanks for your response. I would also think that it should work, when a look at the documentation, but it does not :-(.
I understand that you are busy, but before you look into the code, would it be an idea if I would give you admin rights on the site, so that you can have a quick look at the permissions? Maybe I did something wrong there or maybe I overlooked something ver simple. I'll send you a private message with the login credentials, just in case you are indeed willing and able to give it a go.

Thanks and kind regards,

Onno

ddorian’s picture

Confirmed that it doesn't work.

OnnoRoos’s picture

Dear Alun,

This issue is still open. It now seems that I'm not the only one running into this problem. Again, according to the help in LeagueSite itself, it should work. But is doesn't.

This functionality is much, much needed for the website I'm using LeagueSite for, because there are many Leagues with many teams and matches.

It could still be that I'm missing something, but I wouldn't know what then ;-(

Thanks for any help,

Onno

Alun’s picture

HI guys, i'm sorry for the late reply on this, I just had a quick look at the code and I realised I have not done this.
There is a comment on line 154 of leaguesite_match.module pointing this out!
I am not on a computer where I can test this, but I think the following changes need to be made..

on line 142, the database query needs to be changed to the following:

  $result = db_query("SELECT home_team.uid AS home_owner, away_team.uid AS away_owner, home_team.manager AS home_manager, away_team.manager as away_manager FROM {leaguesite_match} match LEFT JOIN {leaguesite_team} home_team ON match.home_team = home_team.nid LEFT JOIN {leaguesite_team} away_team ON match.away_team = away_team.nid WHERE {node}.type='leaguesite_team' AND {leaguesite_match}.nid = %d", $node->nid);

This should get the managers UID as well as the node owners.
Then we need to update the if statement on line 155 to check all these possible owners.

change it from

if(user_access('enter results for your teams leaguesite_match', $account) && ($account->uid == $row['uid'])){
return TRUE;
}

to this:

//check the managers first
if(user_access('enter results for your teams leaguesite_match', $account) && (($account->uid == $row['home_manager']) || ($account->uid == $row['away_manager']))){
return TRUE;
}
//and now check the node owners
if(user_access('edit own leaguesite_match', $account) && (($account->uid == $row['home_owner']) || ($account->uid == $row['away_owner'])){
return TRUE;
}

That should be along the lines of what needs to be done. Apologies for not having this done sooner. Let me know how it goes. As soon as I get a chance to sort this on my local installation (it doesn't happen often!) I'll make sure it works and commit it.
Thanks
Alun

EDIT: Please be kind with syntax errors if any occur, I typed this off the top of my head into this textbox :-)

OnnoRoos’s picture

StatusFileSize
new62.76 KB

Hi Alun,

Thanks for your reply and solution. But, your code is based on the dev version of LeagueSite, and I'm using the alpha4 version. I can see where I should change the code in alpha 4, it is in row 122 and 135, and not in 142 and 155.

First it didn't work because of a syntax error in row 140 (in the dev version probably row 160). This one was easy to solve. It should have been

$row['away_owner']))) {

instead of

$row['away_owner']))

But then I got the error from the attached picture. This one is less easy to solve. Could it be that the database structure has changed in the dev version? The syntax of the query looks different to me that other queries in the module, but I'm not even sure about this. And it could still be a syntax error which I cannot find.

Any advise is appreciated.

Regards Onno

MasterChief’s picture

StatusFileSize
new1.97 KB

Here the patch.

Where do you have this error OnnoRoos ? (which page)

If i can give you an advice, if you need a version with new features always use dev, a known bug is with the integration with brackets (the integration isn't in alpha 4), if you don't use this you can i think safely choose the dev version.

MasterChief’s picture

Category: support » feature
Status: Active » Needs review
OnnoRoos’s picture

Version: 6.x-1.0-alpha4 » 6.x-1.x-dev
Category: feature » support
StatusFileSize
new84.83 KB
new51.24 KB
new75.63 KB

Dear MasterChief,

Thanks for your support. As you suggested, I updated LeagueSite to the dev version by first deleting the entire LeagueSite module directory. I than run update.php and flushed the cache. After the update, I got the messages that tables had been altered. Whatever I did, no errors, everything worked well.

Then I applied the patch from MasterChief, by manually replacing the old code by the new code. Again an update and flush all caches.

But the error message I posted yesterday remains.

I have a match with node id=100. There are 2 teams here with names "De Grutto's" and "Kryptonite". Guido Vermeulen is captain of the team "De Grutto's". He has role ThymosFloorballCaptains. The permissions for this role are in pic1_Permissions.jpg.

As DrupalAdmin (user 1) when I go to the page for editing this match (http://localhost/Thymos/?q=node/100/edit/score), I get what you see in pic2_Edit_match_as_Admin.jpg.

Everthing is fine.

As Guido Vermeulen when I go to the page for editing this match (http://localhost/Thymos/?q=node/100/edit/score), I get what you see in pic3_Edit_match_as_Guido_Vermeulen.jpg.

Still an error in the SQL syntax. I'm currently using MySQL 5.0.45, this info might help.

Thanks again for any help,

Onno

MasterChief’s picture

Hi again OnnoRoos !

Ok something is definitevely wrong with this :

$result = db_query("SELECT home_team.uid AS home_owner, away_team.uid AS away_owner, home_team.manager AS home_manager, away_team.manager as away_manager FROM {leaguesite_match} match LEFT JOIN {leaguesite_team} home_team ON match.home_team = home_team.nid LEFT JOIN {leaguesite_team} away_team ON match.away_team = away_team.nid WHERE {node}.type='leaguesite_team' AND {leaguesite_match}.nid = %d", $node->nid);

Alun could you give a feedback about this request?

But i think it's not just one error in the syntax but many, tell me if i am wrong about this.

Alun’s picture

Sorry the SQL query was a bit off the mark

$result = db_query("SELECT home_team_node.uid AS home_owner, away_team_node.uid AS away_owner, home_team.manager AS home_manager, away_team.manager as away_manager FROM leaguesite_match LEFT JOIN leaguesite_team home_team ON leaguesite_match.home_team = home_team.team_id LEFT JOIN leaguesite_team away_team ON leaguesite_match.away_team = away_team.team_id LEFT JOIN node home_team_node ON home_team.team_id = home_team_node.nid LEFT JOIN node away_team_node ON away_team.team_id = away_team_node.nid WHERE leaguesite_match.nid = %d", $node->nid);

Should be the right one, at least it throws no syntax errors!

MasterChief’s picture

StatusFileSize
new2.11 KB

Hi Alun!

Here the new patch :)

PS :

Did you see my last post here : http://drupal.org/node/776932 ?

Alun’s picture

StatusFileSize
new12.96 KB

It seems to be working on the alpha4 version, so here is a patch. I'll get one for the dev version - haven't quite figured out the git thing yet!!
Alun

Alun’s picture

StatusFileSize
new1 KB

And here is the dev version!

Alun’s picture

Status: Needs review » Patch (to be ported)
OnnoRoos’s picture

Hello all,

I should have done this much earlier, and I thought I already did, but I can confirm that the patch worked on the dev version. Thanks a lot for this, because it is an important functionality. But now that it works, how can I give a user access to all the matches he/she is allowed to enter the scores? This would be a very useful view to add to the module. Or do I miss an easy way to get to the matches of a certain logged in user

Regards,

Onno

Alun’s picture

Hi Onno,
The match admin screen should be the way they can see all of their matches that they can edit.
Thanks
Alun