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.

Michael Blake made changes - 06/Jan/09 01:54 PM
Field Original Value New Value
Assignee moodle.com [ moodle.com ] Dongsheng Cai [ dongsheng ]
Dongsheng Cai committed 2 files to 'Moodle CVS' on branch 'MOODLE_19_STABLE' - 06/Jan/09 03:52 PM
"MDL-17747, Add Max category depth as a configuratble setting to the site settings, credit goes to Jason Hardin"
MODIFY admin/settings/frontpage.php   Rev. 1.8.2.4    (+8 -1 lines)
MODIFY lang/en_utf8/admin.php   Rev. 1.154.2.74    (+2 -0 lines)
Dongsheng Cai committed 2 files to 'Moodle CVS' - 06/Jan/09 03:52 PM
"MDL-17747, Add Max category depth as a configuratble setting to the site settings, merged from 1.9, credit goes to Jason Hardin"
MODIFY admin/settings/frontpage.php   Rev. 1.12    (+8 -1 lines)
MODIFY lang/en_utf8/admin.php   Rev. 1.253    (+2 -0 lines)
Dongsheng Cai added a comment - 06/Jan/09 03:53 PM
Verified, and patched, thanks Jason.

Dongsheng Cai made changes - 06/Jan/09 03:53 PM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
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?


Tim Hunt made changes - 07/Jan/09 11:53 AM
QA Assignee timhunt
Status Resolved [ 5 ] Reopened [ 4 ]
Resolution Fixed [ 1 ]
Dongsheng Cai added a comment - 07/Jan/09 02:24 PM
A new patch fixed the bugs Tim found out.

Dongsheng Cai made changes - 07/Jan/09 02:24 PM
Attachment MDL-17747.patch [ 16007 ]
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.


Mitsuhiro Yoshida committed 3 files to 'Lang CVS' - 07/Jan/09 04:04 PM
MDL-17747 MDL-17791 Translated new strings for admin.
MDL-9276 Translated new strings for error messages.
MODIFY ja_utf8/error.php   Rev. 1.113    (+5 -1 lines)
MODIFY ja_utf8/README   Rev. 1.911    (+1 -1 lines)
MODIFY ja_utf8/admin.php   Rev. 1.331    (+6 -1 lines)
Dongsheng Cai added a comment - 08/Jan/09 04:55 PM
Thanks Tim.
I attached a new patch here.

Dongsheng Cai made changes - 08/Jan/09 04:55 PM
Attachment MDL-17747-2.patch [ 16023 ]
martignoni committed 1 file to 'Lang CVS' - 11/Jan/09 05:36 PM
MDL-17747, new strings added
MODIFY fr_utf8/admin.php   Rev. 1.332    (+3 -1 lines)
Dongsheng Cai committed 3 files to 'Moodle CVS' on branch 'MOODLE_19_STABLE' - 14/Jan/09 01:47 PM
"MDL-17747, add max category depth setting"
MODIFY course/lib.php   Rev. 1.538.2.69    (+9 -3 lines)
MODIFY admin/settings/frontpage.php   Rev. 1.8.2.5    (+3 -2 lines)
MODIFY lang/en_utf8/admin.php   Rev. 1.154.2.78    (+2 -2 lines)
Dongsheng Cai committed 3 files to 'Moodle CVS' - 14/Jan/09 01:48 PM
"MDL-17747, add max category depth setting, merged from 1.9"
MODIFY admin/settings/frontpage.php   Rev. 1.13    (+3 -2 lines)
MODIFY lang/en_utf8/admin.php   Rev. 1.258    (+2 -2 lines)
MODIFY course/lib.php   Rev. 1.639    (+9 -3 lines)
Dongsheng Cai added a comment - 14/Jan/09 01:48 PM
committed, please review, thanks

Dongsheng Cai made changes - 14/Jan/09 01:48 PM
Status Reopened [ 4 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Tim Hunt added a comment - 20/Jan/09 01:28 PM
Tested and reviewed the code. Good work. Closing.

Tim Hunt made changes - 20/Jan/09 01:28 PM
Status Resolved [ 5 ] Closed [ 6 ]
martignoni committed 1 file to 'Lang CVS' - 23/Jan/09 06:12 AM
MDL-17747 Strings corrected
MODIFY fr_utf8/admin.php   Rev. 1.337    (+3 -3 lines)
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!