Judy Hsu
المواضيع التي نشرها Judy Hsu
Hi all, I'm new to hacking moodle forum module and hope I could get some help from people here.
I noticed that after moodle 1.7(?), when you create a new "forum", the option (pull-down menu) of "Can a student post to this forum" has disappeared. I believe this is now being handled by the role overwrite/permission tab, which to be honest, is sort of confusing and not really user-friendly.
So I'm trying to add this pull-down menu option back to Moodle 1.9.x, and I have located the GUI file (/mod/forum/mod_form.php) and made some changes at around line #35 (see screenshot). However, I'm not familiar with the permission functions and don't know how to tie the front-end GUI codes with the backend. Could anyone please give me some hints or help about how to do that (for example, which file or function I should look into, and what permission/capability functions to use and how to use them)? Thanks guys!
As we have an seperate authentication system and we don't want our teachers to change the course Full name, Short name, Course ID number in the "Edit course settings" page, so I have implemented the following code in the /course/edit_form.php to add a isadmin() check
if (isadmin()) {
$mform->setHelpButton('category', array('coursecategory', get_string('category')));
$mform->setDefault('category', $category->id);
$mform->setType('category', PARAM_INT);
$mform->addElement('text','fullname', get_string('fullname'),'maxlength="254" size="50"');
$mform->setHelpButton('fullname', array('coursefullname', get_string('fullname')), true);
$mform->setDefault('fullname', get_string('defaultcoursefullname'));
$mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
$mform->setType('fullname', PARAM_MULTILANG);
$mform->addElement('text','shortname', get_string('shortname'),'maxlength="100" size="20"');
$mform->setHelpButton('shortname', array('courseshortname', get_string('shortname')), true);
$mform->setDefault('shortname', get_string('defaultcourseshortname'));
$mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
$mform->setType('shortname', PARAM_MULTILANG);
$mform->addElement('text','idnumber', get_string('idnumbercourse'),'maxlength="100" size="10"');
$mform->setHelpButton('idnumber', array('courseidnumber', get_string('idnumbercourse')), true);
$mform->setType('idnumber', PARAM_RAW);
} else {
$mform->addElement('text','fullname', get_string('fullname'),'disabled maxlength="254" size="50"');
$mform->setHelpButton('fullname', array('coursefullname', get_string('fullname')), true);
$mform->addElement('text','shortname', get_string('shortname'),'disabled maxlength="100" size="20"');
$mform->setHelpButton('shortname', array('courseshortname', get_string('shortname')), true);
$mform->addElement('text','idnumber', get_string('idnumbercourse'),'disabled maxlength="100" size="10"');
$mform->setHelpButton('idnumber', array('courseidnumber', get_string('idnumbercourse')), true);
}
However I think in moodle 1.9 this is probably not the best way to implement it as we should probably avoid using isadmin(). However I couldn't find a matching "has_capability()" to implmement this. Any suggestion? Thanks!