Browse files

MDL-26464 improve coding style and fix phpdocs

  • Loading branch information...
1 parent e4e9611 commit 0393a8b706175ab5f31e1a57868b4f89302f47af @skodak skodak committed Mar 14, 2011
Showing with 8 additions and 10 deletions.
  1. +8 −10 mod/data/lib.php
View
18 mod/data/lib.php
@@ -1927,31 +1927,29 @@ function data_print_header($course, $cm, $data, $currenttab='') {
}
/**
- * @global object
+ * Can user add more entries?
+ *
* @param object $data
* @param mixed $currentgroup
* @param int $groupmode
+ * @param stdClass $context
* @return bool
*/
function data_user_can_add_entry($data, $currentgroup, $groupmode, $context = null) {
global $USER;
if (empty($context)) {
- if (!$cm = get_coursemodule_from_instance('data', $data->id)) {
- print_error('invalidcoursemodule');
- }
+ $cm = get_coursemodule_from_instance('data', $data->id, 0, false, MUST_EXIST);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
}
- $haswritecapability = has_capability('mod/data:writeentry', $context);
- $hasmanagecapability = has_capability('mod/data:manageentries', $context);
+ if (has_capability('mod/data:manageentries', $context)) {
+ // no entry limits apply if user can manage
- if (!$haswritecapability && !$hasmanagecapability) {
+ } else if (!has_capability('mod/data:writeentry', $context)) {
return false;
- }
- //check for maximum number of entries
- if ($haswritecapability && !$hasmanagecapability && data_atmaxentries($data)) {
+ } else if (data_atmaxentries($data)) {
return false;
}

0 comments on commit 0393a8b

Please sign in to comment.