Issue Details (XML | Word | Printable)

Key: MDL-17747
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Dongsheng Cai
Reporter: Jason Hardin
Votes: 6
Watchers: 3
Operations

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

Add Max category depth as a configuratble setting to the site settings

Created: 30/Dec/08 09:12 AM   Updated: 11/Feb/09 02:52 AM
Return to search
Component/s: Course
Affects Version/s: 1.9.3
Fix Version/s: None

File Attachments: 1. Text File category_depth.patch (3 kB)
2. Text File MDL-17747-2.patch (4 kB)
3. Text File MDL-17747.patch (4 kB)


Participants: Dongsheng Cai, Jason Hardin, Jeffrey Silverman, Michael Blake and Tim Hunt
Security Level: None
QA Assignee: Tim Hunt
Resolved date: 14/Jan/09
Affected Branches: MOODLE_19_STABLE


 Description  « Hide
We developed this patch for a client to allow them to set max category depth in the site settings rather than being forced to set it in config.php, which we do not allow access to.


 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Michael Blake added a comment - 06/Jan/09 01:54 PM
Dongsheng, please review this patch.

Dongsheng Cai added a comment - 06/Jan/09 03:53 PM
Verified, and patched, thanks Jason.

Tim Hunt added a comment - 07/Jan/09 11:53 AM
I have no idea what this setting is, and the help text does not explain it to me.

Having looked at the code, I can now see, and 50 seems like a stupidly large default. Surely the default should be 0, meaning no limit. (Since this is now in the admin tree, the existing isset logic in course/lib.php is no longer any good.)

Also, if I was doing this, I would probably have fixed the name to be maxcategorydepth, so it followed the coding guidelines, even though that would have been a bigger change.

Rant over.

Jason, do you want to come up with an improved patch?


Dongsheng Cai added a comment - 07/Jan/09 02:24 PM
A new patch fixed the bugs Tim found out.

Tim Hunt added a comment - 07/Jan/09 03:46 PM
isset($CFG->maxcategorydepth) && ($CFG->maxcategorydepth != 0)

would be better as

!empty($CFG->maxcategorydepth)

And sitemaxcategorydepthhelp - Oh, just noticed, all the other strings like this are called something like configsitemaxcategorydepth, anyway - I think

This specifies the maximum depth of nested categories shown when courses are listed on teh site front page.

Also, in the admin setting, the '0' option needs to be displayed as 'Unlimited' instead of 0.


Dongsheng Cai added a comment - 08/Jan/09 04:55 PM
Thanks Tim.
I attached a new patch here.

Dongsheng Cai added a comment - 14/Jan/09 01:48 PM
committed, please review, thanks

Tim Hunt added a comment - 20/Jan/09 01:28 PM
Tested and reviewed the code. Good work. Closing.

Jeffrey Silverman added a comment - 11/Feb/09 02:52 AM
This is just my $0.02 on this: once a naming convention is suggested, it is probably a good idea to stick to it, as the change from the first patch to the second actually creates a regression for anyone who has implemented the first patch.

Note the underscores and lack thereof:

  • if (isset($CFG->max_category_depth) && ($depth >= $CFG->max_category_depth)) {
    + // maxcategorydepth == 0 meant no limit
    + if (!empty($CFG->maxcategorydepth) && $depth >= $CFG->maxcategorydepth) {

Thanks!