Skip to content

Commit

Permalink
Merge branch 'MDL-52335-30' of git://github.com/marinaglancy/moodle i…
Browse files Browse the repository at this point in the history
…nto MOODLE_30_STABLE
  • Loading branch information
David Monllao committed Dec 10, 2015
2 parents 7d8fb19 + f3d159d commit 9887a4c
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 9 deletions.
4 changes: 2 additions & 2 deletions admin/tool/uploaduser/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@
if (isset($USER->$key) and is_array($USER->$key)) {
// this must be some hacky field that is abusing arrays to store content and format
$user->$key = array();
$user->$key['text'] = $value;
$user->$key['format'] = FORMAT_MOODLE;
$user->{$key['text']} = $value;
$user->{$key['format']} = FORMAT_MOODLE;
} else {
$user->$key = trim($value);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@core @core_admin @_file_upload
@tool @tool_uploaduser @_file_upload
Feature: Upload users
In order to add users to the system
As an admin
Expand Down Expand Up @@ -39,3 +39,25 @@ Feature: Upload users
And I follow "Groups"
And I set the field "groups" to "Section 1 (1)"
And the "members" select box should contain "Tom Jones"

@javascript
Scenario: Upload users with custom profile fields
# Create user profile field.
Given I log in as "admin"
And I navigate to "User profile fields" node in "Site administration > Users > Accounts"
And I set the field "datatype" to "Text area"
And I set the following fields to these values:
| Short name | superfield |
| Name | Super field |
And I click on "Save changes" "button"
# Upload users.
When I navigate to "Upload users" node in "Site administration > Users > Accounts"
And I upload "lib/tests/fixtures/upload_users_profile.csv" file to "File" filemanager
And I press "Upload users"
And I press "Upload users"
# Check that users were created and the superfield is filled.
And I navigate to "Browse list of users" node in "Site administration > Users > Accounts"
And I follow "Tom Jones"
And I should see "Super field"
And I should see "The big guy"
And I log out
8 changes: 4 additions & 4 deletions lib/jabber/XMPP/XMLStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ public function endXML($parser, $name) {
if ($searchxml !== null) {
if($handler[2] === null) $handler[2] = $this;
$this->log->log("Calling {$handler[1]}", XMPPHP_Log::LEVEL_DEBUG);
$handler[2]->$handler[1]($this->xmlobj[2]);
$handler[2]->{$handler[1]}($this->xmlobj[2]);
}
}
}
Expand All @@ -578,13 +578,13 @@ public function endXML($parser, $name) {
if($searchxml !== null and $searchxml->name == $handler[0] and ($searchxml->ns == $handler[1] or (!$handler[1] and $searchxml->ns == $this->default_ns))) {
if($handler[3] === null) $handler[3] = $this;
$this->log->log("Calling {$handler[2]}", XMPPHP_Log::LEVEL_DEBUG);
$handler[3]->$handler[2]($this->xmlobj[2]);
$handler[3]->{$handler[2]}($this->xmlobj[2]);
}
}
foreach($this->idhandlers as $id => $handler) {
if(array_key_exists('id', $this->xmlobj[2]->attrs) and $this->xmlobj[2]->attrs['id'] == $id) {
if($handler[1] === null) $handler[1] = $this;
$handler[1]->$handler[0]($this->xmlobj[2]);
$handler[1]->{$handler[0]}($this->xmlobj[2]);
#id handlers are only used once
unset($this->idhandlers[$id]);
break;
Expand Down Expand Up @@ -640,7 +640,7 @@ public function event($name, $payload = null) {
if($handler[2] === null) {
$handler[2] = $this;
}
$handler[2]->$handler[1]($payload);
$handler[2]->{$handler[1]}($payload);
}
}
foreach($this->until as $key => $until) {
Expand Down
1 change: 1 addition & 0 deletions lib/jabber/readme_moodle.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Description of XMPPHP (aka jabber) version 0.1rc2-r77 library import into Moodle

MDL-20876 - replaced deprecated split() with explode()
MDL-52335 - PHP7 variable syntax changes
3 changes: 3 additions & 0 deletions lib/tests/fixtures/upload_users_profile.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
username,password,firstname,lastname,email,profile_field_superfield
jonest,verysecret,Tom,Jones,jonest@someplace.edu,The big guy
reznort,somesecret,Trent,Reznor,reznort@someplace.edu,Loves cats
2 changes: 1 addition & 1 deletion mod/data/field/textarea/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function update_content($recordid, $value, $name='') {
// the value will be retrieved by file_get_submitted_draft_itemid, do not need to save in DB
return true;
} else {
$content->$names[2] = clean_param($value, PARAM_NOTAGS); // content[1-4]
$content->{$names[2]} = clean_param($value, PARAM_NOTAGS); // content[1-4]
}
} else {
$content->content = clean_param($value, PARAM_CLEAN);
Expand Down
2 changes: 1 addition & 1 deletion mod/lti/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ function lti_parse_custom_parameter($toolproxy, $tool, $params, $value, $islti2)
$value = $params[$val];
} else {
$valarr = explode('->', substr($val, 1), 2);
$value = "{${$valarr[0]}->$valarr[1]}";
$value = "{${$valarr[0]}->{$valarr[1]}}";
$value = str_replace('<br />' , ' ', $value);
$value = str_replace('<br>' , ' ', $value);
$value = format_string($value);
Expand Down
9 changes: 9 additions & 0 deletions mod/lti/tests/locallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@
class mod_lti_locallib_testcase extends advanced_testcase {

public function test_split_custom_parameters() {
$this->resetAfterTest();

$tool = new stdClass();
$tool->enabledcapability = '';
$tool->parameter = '';
$this->assertEquals(lti_split_custom_parameters(null, $tool, array(), "x=1\ny=2", false),
array('custom_x' => '1', 'custom_y' => '2'));

Expand All @@ -76,6 +79,12 @@ public function test_split_custom_parameters() {
$this->assertEquals(lti_split_custom_parameters(null, $tool, array(),
'Complex!@#$^*(){}[]KEY=Complex!@#$^*;(){}[]½Value', false),
array('custom_complex____________key' => 'Complex!@#$^*;(){}[]½Value'));

// Test custom parameter that returns $USER property.
$user = $this->getDataGenerator()->create_user(array('middlename' => 'SOMETHING'));
$this->setUser($user);
$this->assertEquals(array('custom_x' => '1', 'custom_y' => 'SOMETHING'),
lti_split_custom_parameters(null, $tool, array(), "x=1\ny=\$Person.name.middle", false));
}

/**
Expand Down

0 comments on commit 9887a4c

Please sign in to comment.