$string['glossary:approve'] = 'Approve unapproved entries';
$string['glossary:comment'] = 'Create comments';
$string['glossary:export'] = 'Export entries';
+$string['glossary:exportentry'] = 'Export single entry';
+$string['glossary:exportownentry'] = 'Export single entry of yours';
$string['glossary:import'] = 'Import entries';
$string['glossary:managecategories'] = 'Manage categories';
$string['glossary:managecomments'] = 'Manage comments';
)
),
+ 'mod/glossary:exportentry' => array(
+
+ 'riskbitmask' => RISK_PERSONAL,
+
+ 'captype' => 'read',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'legacy' => array(
+ 'teacher' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ 'admin' => CAP_ALLOW
+ )
+ ),
+
+ 'mod/glossary:exportownentry' => array(
+
+ 'captype' => 'read',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'legacy' => array(
+ 'teacher' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ 'admin' => CAP_ALLOW,
+ 'student' => CAP_ALLOW,
+ )
+ ),
+
);
?>
</div>
</form>
<?php
- if ($DB->count_records('glossary_entries', array('glossaryid' => $glossary->id)) && true) { // @todo penny capability check
+ // don't need cap check here, we share with the general export.
+ if ($DB->count_records('glossary_entries', array('glossaryid' => $glossary->id))) {
require_once($CFG->libdir . '/portfoliolib.php');
$p = array(
'id' => $cm->id,
$return .= " <font size=\"-1\">" . get_string("exportedentry","glossary") . "</font>";
}
}
- if (true) { // @todo penny add capability check
+ if (has_capability('mod/glossary:exportentry', $context)
+ || ($entry->userid == $USER->id
+ && has_capability('mod/glossary:exportownentry', $context))) {
require_once($CFG->libdir . '/portfoliolib.php');
$p = array(
'id' => $cm->id,
}
public function check_permissions() {
- // @todo
- return true;
+ return has_capability('mod/glossary:export', get_context_instance(CONTEXT_MODULE, $this->cm->id));
}
public static function display_name() {
|| !$this->entry = $DB->get_record('glossary_entries', array('id' => $callbackargs['entryid']))) {
portfolio_exporter::raise_error('noentry', 'glossary');
}
- /*
- $aliases = $DB->get_records('glossary_alias', array('entryid' => $this->entry->id));
- $categories = $DB->get_records_sql('SELECT ec.entryid, c.name
- FROM {glossary_entries_categories} ec
- JOIN {glossary_categories} c
- ON c.id = ec.categoryid
- WHERE ec.entryid = ?', array($this->entry->id));
- */
}
public function expected_time() {
}
public function check_permissions() {
- //@ penny todo
- return true;
+ $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
+ return has_capability('mod/glossary:exportentry', $context)
+ || ($this->entry->userid == $this->user->id && has_capability('mod/glossary:exportownentry', $context));
}
public static function display_name() {
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2008081900;
+$module->version = 2008081901;
$module->requires = 2008081600; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)