Issue Details (XML | Word | Printable)

Key: MDL-17143
Type: Sub-task Sub-task
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Dongsheng Cai
Reporter: Martin Dougiamas
Votes: 2
Watchers: 5
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle
MDL-17107

Don't display the user description at all when user isn't enrolled in any courses

Created: 06/Nov/08 01:01 PM   Updated: 17/Feb/09 10:46 AM
Return to search
Component/s: Administration
Affects Version/s: 1.9.3
Fix Version/s: 1.6.9, 1.7.7, 1.8.8, 1.9.4

File Attachments: 1. Text File MDL-17143.patch (7 kB)

Issue Links:
Relates
 

Participants: Dongsheng Cai, Eloy Lafuente (stronk7), Helen Foster, Jerome Mouneyrac, Martin Dougiamas and Petr Skoda
Security Level: None
QA Assignee: Jerome Mouneyrac
Difficulty: Easy
Resolved date: 19/Nov/08
Affected Branches: MOODLE_19_STABLE
Fixed Branches: MOODLE_16_STABLE, MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE


 Description  « Hide
1. Add a new config variable profilesforenrolledusersonly = true (by default)

2. When showing the profile page, if a courseid isn't defined (this is the public view) AND the user is not enrolled in any courses AND profilesforenrolledusersonly = true then replace the profile description with something like "This profile description will not be shown until this person is enrolled in at least one course".

3. When editing the profile page, if the description is blank AND the user is not enrolled in any courses AND profilesforenrolledusersonly = true then completely hide the description field from the editing page.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Dongsheng Cai added a comment - 10/Nov/08 11:14 AM
a patch against 1.9

Dongsheng Cai added a comment - 10/Nov/08 11:51 AM
The new patch allows administrators editing description anytime

Dongsheng Cai added a comment - 10/Nov/08 12:07 PM
Committed to 1.9 and HEAD, please review.

Dongsheng Cai added a comment - 10/Nov/08 12:15 PM
Please review.

Petr Skoda added a comment - 11/Nov/08 04:10 PM
you can not use get_record('role_assignments', 'userid', $userid) if there are multiple role assignments - it should some debugging error

instead please use record_exists()


Petr Skoda added a comment - 11/Nov/08 04:16 PM
also please reorder the if condition so that the record_exists() is executed only when really needed

Eloy Lafuente (stronk7) added a comment - 12/Nov/08 04:19 AM
Oki, I've:
  • Added some empty() checks to avoid some notices about the $CFG->profilesforenrolledusersonly not defined.
  • Changed get_record() to record_exists() and moved it to last condition.
  • Bump 19_STABLE and HEAD versions to force the setting to be displayed/defined.

TODO:

1) I'd fix the setting help text a bit, indicating it's an anti-spam measure in some way. Right now the justification of the setting isn't clear IMO.
2) Add it to the anti SPAM Moodle Docs.
3) Backport from 19_STABLE to 1.8, 1.7 and 1.6

Helen can you take a look to 1 & 2, plz...
Dongsheng can backport it to be ready next weekly?

Thanks everybody!
Thanks and ciao


Helen Foster added a comment - 12/Nov/08 09:09 PM
1) How about:

$string['configprofilesforenrolledusersonly'] = 'To prevent misuse by spammers, profile descriptions of users who are not yet enrolled in any course are hidden. New users must enrol in at least one course before they can add a profile description.';


Helen Foster added a comment - 12/Nov/08 09:28 PM

Eloy Lafuente (stronk7) added a comment - 13/Nov/08 06:35 PM
Looks perfect for me, Helen. +1

Thanks!


Helen Foster added a comment - 13/Nov/08 08:39 PM
Thanks Eloy, reworded lang string added to HEAD, 1.9 and 1.8.

Eloy Lafuente (stronk7) added a comment - 14/Nov/08 02:59 AM
Great! BTW... looking commits... I thin the setting has been backported to 1.7 too.

Ciao


Helen Foster added a comment - 14/Nov/08 07:25 AM
Thanks Eloy, I've added the reworded lang string to 1.7 too and have updated the documentation.

Dongsheng Cai added a comment - 14/Nov/08 09:50 AM
Hi, everyone, 1.6 is quite different from the other versions. Where should I place the profilesforenrolledusersonly setting in "Administration Page"?

Eloy Lafuente (stronk7) added a comment - 17/Nov/08 07:13 PM
Good question... hehe.

I think it used to be a "security" section under "config variables" or something like that. That was the place where things like $CFG->secureforms or $CFG->loginhttps were defined... hope it helps.


Eloy Lafuente (stronk7) added a comment - 19/Nov/08 01:39 AM
I've performed some changes in the 16_STABLE version committed some hours ago:
  • Set new setting default to true (securer).
  • clean some debug code that was left there.
  • fixed use of undefined $userid
  • fixed logic so description field continues being mandatory for normal (enrolled) users. Was broked in prev commit.

Seems to be working fine now. Resolving as fixed. Someone else, please, review this. Ciao

PS: And please, try to perform some test when committing things to stable branches. This was simply broken in too many places to be acceptable IMO. TIA!


Petr Skoda added a comment - 19/Nov/08 05:52 AM
hmm,

1/ I am not sure this should be on by default - when adding new user the description field "disappears" ??

2/ I can see this in 1.6.x when I view my own profile and description already there, but not enrolled: "This profile description will not be shown until this person is enrolled in at least one course." and not enrolled yet. This does not seem like correct English.

Anyway, reopening and going to fix more coding problems there...

Petr


Petr Skoda added a comment - 19/Nov/08 06:43 AM
1/ fixed undefined 2x $userid in 1.6.x

2/ fixe 1x undefined $userid in 1.7.x, BUT the use of non-existent capability moodle/user:editprofile will not probably work in all cases - this was a know problem fixed in 1.8.x only - maybe it is the right time to close 1.7.x branch and not commit anything there at all

3/ in 1.8.x the new code in definition_after_data() MUST verify that $userid is valid (changed in 1.9.x) - it was removing the description field always - this was totally untested, right?

4/ the restriction does not belong into advanced user edit form - it was removing the description if user had only create user cap


Jerome Mouneyrac added a comment - 17/Feb/09 10:46 AM
Tested on 1.9. It works fine, thanks everybody.