@@ -16,7 +16,6 @@ |
||
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * class based on core/admin/uu_progress_tracker by Petr Skoda |
| 19 | - |
|
| 20 | 19 | * @package local_relationship |
| 21 | 20 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
| 22 | 21 | */ |
@@ -57,16 +57,16 @@ |
||
| 57 | 57 | $table->tablealign = 'center'; |
| 58 | 58 | |
| 59 | 59 | $table->head = array(get_string('titleline', 'local_relationship')); |
| 60 | - $table->align = array ('right'); |
|
| 61 | - foreach($this->columns AS $col) { |
|
| 62 | - $table->head[] = get_string('title'.$col, 'local_relationship'); |
|
| 60 | + $table->align = array('right'); |
|
| 61 | + foreach ($this->columns AS $col) { |
|
| 62 | + $table->head[] = get_string('title' . $col, 'local_relationship'); |
|
| 63 | 63 | $table->align[] = 'left'; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | $table->data = array(); |
| 67 | 67 | foreach ($this->rows AS $linenum => $r) { |
| 68 | 68 | $row = array($linenum . '.'); |
| 69 | - foreach($r AS $col=>$occurs) { |
|
| 69 | + foreach ($r AS $col=>$occurs) { |
|
| 70 | 70 | $text = ''; |
| 71 | 71 | foreach ($occurs AS $occur) { |
| 72 | 72 | $msg = html_writer::tag('div', $occur['msg'], array('class' => 'alert-' . $occur['level'])); |
@@ -21,11 +21,11 @@ |
||
| 21 | 21 | $settings->add(new admin_setting_heading('local_relationship/settings', get_string('massassignusers', 'local_relationship'), get_string('massassignusers_desc', 'local_relationship'))); |
| 22 | 22 | |
| 23 | 23 | $optionsauthtype = array(); |
| 24 | - foreach(get_enabled_auth_plugins(false) as $opt){ |
|
| 24 | + foreach (get_enabled_auth_plugins(false) as $opt) { |
|
| 25 | 25 | $optionsauthtype[$opt] = $opt; |
| 26 | 26 | } |
| 27 | 27 | $settings->add(new admin_setting_configselect('local_relationship/authtype', get_string('authtype', 'local_relationship'), |
| 28 | - get_string('authtype_desc', 'local_relationship') ,'manual', $optionsauthtype)); |
|
| 28 | + get_string('authtype_desc', 'local_relationship'), 'manual', $optionsauthtype)); |
|
| 29 | 29 | |
| 30 | 30 | $options = array(0=>get_string('no'), 1=>get_string('yes')); |
| 31 | 31 | $setting = new admin_setting_configselect('local_relationship/searchsccp', get_string('searchsccp', 'local_relationship'), |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | require_once($CFG->dirroot . '/user/selector/lib.php'); |
| 27 | 27 | require_once($CFG->dirroot . '/tag/lib.php'); |
| 28 | 28 | |
| 29 | -function relationship_set_header($context, $url, $relationship=null, $module=null) { |
|
| 29 | +function relationship_set_header($context, $url, $relationship = null, $module = null) { |
|
| 30 | 30 | global $PAGE, $COURSE, $DB; |
| 31 | 31 | |
| 32 | 32 | if ($context->contextlevel != CONTEXT_COURSECAT) { |
@@ -43,27 +43,27 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $PAGE->navbar->add($category->name, new moodle_url('/course/index.php', array('categoryid'=>$category->id))); |
| 45 | 45 | $PAGE->navbar->add($navtitle, new moodle_url('/local/relationship/index.php', array('contextid'=>$context->id))); |
| 46 | - if($module) { |
|
| 46 | + if ($module) { |
|
| 47 | 47 | $PAGE->navbar->add(get_string($module, 'local_relationship'), |
| 48 | 48 | new moodle_url("/local/relationship/{$module}.php", array('relationshipid'=>$relationship->id))); |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | -function relationship_set_title($relationship=null, $action=null, $param=null) { |
|
| 52 | +function relationship_set_title($relationship = null, $action = null, $param = null) { |
|
| 53 | 53 | global $OUTPUT; |
| 54 | 54 | |
| 55 | 55 | echo $OUTPUT->header(); |
| 56 | - if($relationship) { |
|
| 56 | + if ($relationship) { |
|
| 57 | 57 | echo $OUTPUT->heading(get_string('relationship', 'local_relationship') . ': ' . format_string($relationship->name)); |
| 58 | 58 | echo html_writer::empty_tag('BR'); |
| 59 | 59 | } |
| 60 | - if($action) { |
|
| 60 | + if ($action) { |
|
| 61 | 61 | echo $OUTPUT->heading(get_string($action, 'local_relationship', $param), '4'); |
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | -function relationship_groups_parse_name($format, $value, $value_is_a_name=false) { |
|
| 66 | - if($value_is_a_name) { |
|
| 65 | +function relationship_groups_parse_name($format, $value, $value_is_a_name = false) { |
|
| 66 | + if ($value_is_a_name) { |
|
| 67 | 67 | if (strstr($format, '@') !== false) { |
| 68 | 68 | $str = str_replace('@', $value, $format); |
| 69 | 69 | } else { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } else { |
| 73 | 73 | if (strstr($format, '@') !== false) { // Convert $value to a character series |
| 74 | 74 | $letter = 'A'; |
| 75 | - for($i=0; $i<$value; $i++) { |
|
| 75 | + for ($i = 0; $i < $value; $i++) { |
|
| 76 | 76 | $letter++; |
| 77 | 77 | } |
| 78 | 78 | $str = str_replace('@', $letter, $format); |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | $all_roles = role_get_names(); |
| 88 | 88 | $ctx_roles = get_roles_for_contextlevels(CONTEXT_COURSE); |
| 89 | 89 | $roles = array(); |
| 90 | - foreach($ctx_roles AS $id=>$roleid) { |
|
| 91 | - if($roleid > 2) { |
|
| 90 | + foreach ($ctx_roles AS $id=>$roleid) { |
|
| 91 | + if ($roleid > 2) { |
|
| 92 | 92 | $roles[$roleid] = $all_roles[$roleid]->localname; |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | $context = context::instance_by_id($relationship->contextid); |
| 104 | 104 | |
| 105 | 105 | $contextids = array(); |
| 106 | - foreach($context->get_parent_context_ids(true) as $ctxid) { |
|
| 106 | + foreach ($context->get_parent_context_ids(true) as $ctxid) { |
|
| 107 | 107 | $context = context::instance_by_id($ctxid); |
| 108 | 108 | if (has_capability('moodle/cohort:view', $context)) { |
| 109 | 109 | $contextids[] = $ctxid; |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | AND g.idnumber NOT LIKE 'relationship_{$relationshipid}_%' |
| 140 | 140 | ORDER BY g.name"; |
| 141 | 141 | $groups = array(); |
| 142 | - foreach($DB->get_records_sql($sql, array('relationshipid'=>$relationshipid)) as $r) { |
|
| 142 | + foreach ($DB->get_records_sql($sql, array('relationshipid'=>$relationshipid)) as $r) { |
|
| 143 | 143 | $groups[$r->name][] = $r; |
| 144 | 144 | } |
| 145 | 145 | return $groups; |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | $allrelationships = $DB->count_records('relationship', array('contextid'=>$contextid)); |
| 224 | 224 | $totalrelationships = $DB->count_records_sql($countfields . $sql, $params); |
| 225 | 225 | $relationships = $DB->get_records_sql($fields . $sql . $order, $params, $page*$perpage, $perpage); |
| 226 | - foreach($relationships as $rl) { |
|
| 226 | + foreach ($relationships as $rl) { |
|
| 227 | 227 | $rl->tags = core_tag_tag::get_item_tags_array('relationship', 'relationship', $rl->id); |
| 228 | 228 | } |
| 229 | 229 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * @return mixed |
| 242 | 242 | * @throws coding_exception |
| 243 | 243 | */ |
| 244 | -function relationship_get_cohort_by_roleshortname($relationshipid, $roleshortname, $strictness=IGNORE_MISSING) { |
|
| 244 | +function relationship_get_cohort_by_roleshortname($relationshipid, $roleshortname, $strictness = IGNORE_MISSING) { |
|
| 245 | 245 | global $DB; |
| 246 | 246 | |
| 247 | 247 | $sql = "SELECT rc.*, ch.name, ch.component, r.name rolename |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | return $OUTPUT->box($text, 'generalbox', 'notice'); |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | -function relationship_print_tabs($url, $tabs, $action='') { |
|
| 269 | +function relationship_print_tabs($url, $tabs, $action = '') { |
|
| 270 | 270 | global $OUTPUT; |
| 271 | 271 | |
| 272 | 272 | if (is_array($tabs) && count($tabs) > 1) { |
@@ -25,14 +25,14 @@ discard block |
||
| 25 | 25 | defined('MOODLE_INTERNAL') || die(); |
| 26 | 26 | |
| 27 | 27 | use local_relationship\mass_assign_processor; |
| 28 | -require_once($CFG->dirroot.'/lib/formslib.php'); |
|
| 28 | +require_once($CFG->dirroot . '/lib/formslib.php'); |
|
| 29 | 29 | |
| 30 | 30 | class mass_assign extends \moodleform { |
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * Form Definition |
| 34 | 34 | */ |
| 35 | - function definition () { |
|
| 35 | + function definition() { |
|
| 36 | 36 | |
| 37 | 37 | $mform = $this->_form; |
| 38 | 38 | $relationshipgroup = $this->_customdata['data']; |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $rcs = relationship_get_cohort_by_roleshortname($relationshipgroup->relationshipid, 'student'); |
| 49 | 49 | |
| 50 | 50 | $cohortrole = get_string('none'); |
| 51 | - if($rcs) { |
|
| 51 | + if ($rcs) { |
|
| 52 | 52 | $r = get_string('role'); |
| 53 | 53 | $cohortrole = "{$rcs->name} ({$r}: $rcs->rolename)"; |
| 54 | 54 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $mform->addHelpButton('allowallusers', 'allowallusers', 'local_relationship'); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if(mass_assign_processor::search_sccp()) { |
|
| 71 | + if (mass_assign_processor::search_sccp()) { |
|
| 72 | 72 | $mform->addElement('checkbox', 'registerpendencies', get_string('registerpendencies', 'local_relationship'), false); |
| 73 | 73 | $mform->addHelpButton('registerpendencies', 'registerpendencies', 'local_relationship'); |
| 74 | 74 | } |
@@ -22,9 +22,9 @@ discard block |
||
| 22 | 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | -require_once(__DIR__.'/../../config.php'); |
|
| 26 | -require($CFG->dirroot.'/local/relationship/lib.php'); |
|
| 27 | -require_once($CFG->dirroot.'/local/relationship/locallib.php'); |
|
| 25 | +require_once(__DIR__ . '/../../config.php'); |
|
| 26 | +require($CFG->dirroot . '/local/relationship/lib.php'); |
|
| 27 | +require_once($CFG->dirroot . '/local/relationship/locallib.php'); |
|
| 28 | 28 | |
| 29 | 29 | require_login(); |
| 30 | 30 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | // Therefore, the mass assign only works in cohort without component. |
| 39 | 39 | // When uniform distribution is enabled, users are uniformly distribute to any group with uniformdistribution = 1 in the relationship, |
| 40 | 40 | // so uniform distribution needs to be disabled to mass assign users in a specific group. |
| 41 | -if(!empty($relationshipcohort->component) || $relationshipcohort->uniformdistribution || $relationshipgroup->uniformdistribution) { |
|
| 41 | +if (!empty($relationshipcohort->component) || $relationshipcohort->uniformdistribution || $relationshipgroup->uniformdistribution) { |
|
| 42 | 42 | print_error('cantmassassign', 'local_relationship'); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $rcs = relationship_get_cohort_by_roleshortname($relationshipgroup->relationshipid, 'student'); |
| 127 | 127 | |
| 128 | 128 | $cohortrole = get_string('none'); |
| 129 | - if($rcs) { |
|
| 129 | + if ($rcs) { |
|
| 130 | 130 | $r = get_string('role'); |
| 131 | 131 | $cohortrole = "{$rcs->name} ({$r}: $rcs->rolename)"; |
| 132 | 132 | } |
@@ -137,9 +137,9 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | $recs = $DB->get_records('relationship_pendencies', array('relationshipgroupid'=>$relationshipgroup->id, 'relationshipcohortid'=>$relationshipcohort->id), 'cpf'); |
| 139 | 139 | $table = new html_table(); |
| 140 | - $table->head = array('CPF', get_string('timecreated', 'local_relationship')); |
|
| 140 | + $table->head = array('CPF', get_string('timecreated', 'local_relationship')); |
|
| 141 | 141 | $table->data = array(); |
| 142 | - foreach($recs AS $rec) { |
|
| 142 | + foreach ($recs AS $rec) { |
|
| 143 | 143 | $line = array($rec->cpf, userdate($rec->timecreated)); |
| 144 | 144 | $baseurl->param('id', $rec->id); |
| 145 | 145 | $baseurl->param('delete', 1); |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | defined('MOODLE_INTERNAL') || die(); |
| 25 | 25 | |
| 26 | -require_once($CFG->dirroot.'/local/relationship/lib.php'); |
|
| 26 | +require_once($CFG->dirroot . '/local/relationship/lib.php'); |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Event handler for relationship local plugin. |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $idnumber = $DB->get_field('user', 'idnumber', array('id'=>$event->userid)); |
| 115 | 115 | if (!empty($idnumber)) { |
| 116 | 116 | $pessoas = \local_ufsc\pessoa::by_key('idpessoa', $idnumber); |
| 117 | - if(!empty($pessoas)) { |
|
| 117 | + if (!empty($pessoas)) { |
|
| 118 | 118 | $pessoa = reset($pessoas); |
| 119 | 119 | if (!empty($pessoa->cpf)) { |
| 120 | 120 | $where = 'rp.cpf = :cpf'; |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | if (!empty($rec->relationshipcohortid) && !empty($rec->relationshipgroupid)) { |
| 131 | 131 | $massassign = new \local_relationship\mass_assign_processor($rec->relationshipcohortid, $rec->relationshipgroupid, false, $rec->allowallusers); |
| 132 | 132 | $result = $massassign->process_relationship($event->userid); |
| 133 | - if (in_array($result->summary,['assigneduser', 'alreadyingroup'])) { |
|
| 133 | + if (in_array($result->summary, ['assigneduser', 'alreadyingroup'])) { |
|
| 134 | 134 | $DB->delete_records('relationship_pendencies', array('id' => $rec->id)); |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | defined('MOODLE_INTERNAL') || die(); |
| 27 | 27 | |
| 28 | -require_once($CFG->dirroot.'/cohort/lib.php'); |
|
| 28 | +require_once($CFG->dirroot . '/cohort/lib.php'); |
|
| 29 | 29 | |
| 30 | 30 | class mass_assign_processor { |
| 31 | 31 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | private $registerpendencies; |
| 37 | 37 | private $allowallusers; |
| 38 | 38 | |
| 39 | - public function __construct($relationshipcohortid, $relationshipgroupid, $registerpendencies=false, $allowallusers=false, $authtype='') { |
|
| 39 | + public function __construct($relationshipcohortid, $relationshipgroupid, $registerpendencies = false, $allowallusers = false, $authtype = '') { |
|
| 40 | 40 | global $DB; |
| 41 | 41 | |
| 42 | 42 | $this->relationshipcohort = relationship_get_cohort($relationshipcohortid); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $this->relationshipgroup = $DB->get_record('relationship_groups', array('id' => $relationshipgroupid), '*', MUST_EXIST); |
| 48 | - if($this->relationshipgroup->uniformdistribution) { |
|
| 48 | + if ($this->relationshipgroup->uniformdistribution) { |
|
| 49 | 49 | throw new \moodle_exception('cantmassassign', 'local_relationship'); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | 'level' => 'error' |
| 416 | 416 | ]; |
| 417 | 417 | } else { |
| 418 | - $data = (object)$params; |
|
| 418 | + $data = (object) $params; |
|
| 419 | 419 | $data->timecreated = time(); |
| 420 | 420 | $DB->insert_record('relationship_pendencies', $data); |
| 421 | 421 | $result->summary = 'registeredaspending'; |
@@ -443,9 +443,9 @@ discard block |
||
| 443 | 443 | } else { |
| 444 | 444 | for ($t = 9; $t < 11; $t++) { |
| 445 | 445 | for ($d = 0, $c = 0; $c < $t; $c++) { |
| 446 | - $d += $cpf{$c} * (($t + 1) - $c); |
|
| 446 | + $d += $cpf{$c}*(($t+1)-$c); |
|
| 447 | 447 | } |
| 448 | - $d = ((10 * $d) % 11) % 10; |
|
| 448 | + $d = ((10*$d)%11)%10; |
|
| 449 | 449 | if ($cpf{$c} != $d) { |
| 450 | 450 | return false; |
| 451 | 451 | } |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | -require_once(__DIR__.'/../../config.php'); |
|
| 25 | -require($CFG->dirroot.'/local/relationship/lib.php'); |
|
| 26 | -require_once($CFG->dirroot.'/local/relationship/locallib.php'); |
|
| 27 | -require_once($CFG->libdir.'/adminlib.php'); |
|
| 24 | +require_once(__DIR__ . '/../../config.php'); |
|
| 25 | +require($CFG->dirroot . '/local/relationship/lib.php'); |
|
| 26 | +require_once($CFG->dirroot . '/local/relationship/locallib.php'); |
|
| 27 | +require_once($CFG->libdir . '/adminlib.php'); |
|
| 28 | 28 | |
| 29 | 29 | require_login(); |
| 30 | 30 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | if ($editable) { |
| 67 | 67 | $url = new moodle_url('/local/relationship/edit_group.php', array('relationshipgroupid' => $relationshipgroup->id, 'uniformdistribution' => $uniformdistribution)); |
| 68 | - $line[] = $status.' ('.html_writer::link($url, $text).')'; |
|
| 68 | + $line[] = $status . ' (' . html_writer::link($url, $text) . ')'; |
|
| 69 | 69 | } else { |
| 70 | 70 | $line[] = $status; |
| 71 | 71 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | if ($manager || $canassign) { |
| 81 | 81 | $buttons[] = html_writer::link(new moodle_url('/local/relationship/assign.php', array('relationshipgroupid' => $relationshipgroup->id)), |
| 82 | 82 | html_writer::span($OUTPUT->pix_icon('t/assignroles', get_string('assign', 'local_relationship'), 'moodle', ['class' => 'iconsmall']))); |
| 83 | - if($relationshipcohort && empty($relationshipcohort->component) && !$relationshipcohort->uniformdistribution && !$relationshipgroup->uniformdistribution) { |
|
| 83 | + if ($relationshipcohort && empty($relationshipcohort->component) && !$relationshipcohort->uniformdistribution && !$relationshipgroup->uniformdistribution) { |
|
| 84 | 84 | $buttons[] = html_writer::link(new moodle_url('/local/relationship/mass_assign.php', array('relationshipgroupid' => $relationshipgroup->id)), |
| 85 | 85 | html_writer::span($OUTPUT->pix_icon('t/add', get_string('massassign', 'local_relationship'), 'moodle', ['class' => 'iconsmall']))); |
| 86 | 86 | } |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | $table = new html_table(); |
| 93 | 93 | $table->head = array(get_string('name', 'local_relationship'), |
| 94 | 94 | get_string('memberscount', 'local_relationship'), |
| 95 | - get_string('limit', 'local_relationship').$OUTPUT->help_icon('userlimit', 'local_relationship'), |
|
| 96 | - get_string('uniformdistribute', 'local_relationship').$OUTPUT->help_icon('uniformdistribute', 'local_relationship'), |
|
| 95 | + get_string('limit', 'local_relationship') . $OUTPUT->help_icon('userlimit', 'local_relationship'), |
|
| 96 | + get_string('uniformdistribute', 'local_relationship') . $OUTPUT->help_icon('uniformdistribute', 'local_relationship'), |
|
| 97 | 97 | get_string('edit')); |
| 98 | 98 | $table->colclasses = array('leftalign name', |
| 99 | 99 | 'leftalign size', |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | $addgroup = new single_button(new moodle_url('/local/relationship/edit_group.php', array('relationshipid' => $relationshipid)), get_string('addgroup', 'local_relationship')); |
| 142 | 142 | $addgroups = new single_button(new moodle_url('/local/relationship/autogroup.php', array('relationshipid' => $relationshipid)), get_string('autogroup', 'local_relationship')); |
| 143 | - echo html_writer::tag('div', $OUTPUT->render($addgroup).$OUTPUT->render($addgroups), array('class' => 'buttons')); |
|
| 143 | + echo html_writer::tag('div', $OUTPUT->render($addgroup) . $OUTPUT->render($addgroups), array('class' => 'buttons')); |
|
| 144 | 144 | } else if ($manager) { |
| 145 | 145 | echo $OUTPUT->heading(get_string('noeditable', 'local_relationship')); |
| 146 | 146 | } |